Skip to content

Commit

Permalink
Merge pull request #19 from Iryna-Pavlyk/users6
Browse files Browse the repository at this point in the history
Change data in error-messages
  • Loading branch information
Iryna-Pavlyk authored Aug 6, 2024
2 parents ef55703 + c98eafa commit 4ea4c51
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const signupController = async (req, res) => {
const { email } = req.body;
const user = await findUser({ email });
if (user) {
throw createHttpError(409, 'Email in use');
throw createHttpError(409, 'Email in use!');
}

const newUser = await signup(req.body);
Expand Down
5 changes: 2 additions & 3 deletions src/middlewares/errorHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ export const errorHandler = (err, req, res, next) => {
res.status(err.status).json({
status: err.status,
message: err.name,
data: err.message,
data: { message: err.message },
});
}

res.status(500).json({
status: 500,
message: 'Something went wrong',
data: err.message,
data: { message: 'Something went wrong' },
});
};
2 changes: 1 addition & 1 deletion src/middlewares/notFoundHandler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const notFoundHandler = (req, res) => {
res.status(404).json({
status: 404,
message: 'Not found',
data: { message: 'Not found' },
});
};

0 comments on commit 4ea4c51

Please sign in to comment.