Skip to content

Commit

Permalink
fix: wrap backend errors in json messages (#1991)
Browse files Browse the repository at this point in the history
  • Loading branch information
halfwhole authored and gweiying committed Oct 6, 2022
1 parent 68a10fc commit 9a9b8f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/server/modules/user/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class UserController {
const queryConditions = UserController.extractUrlQueryConditions(req)
const validationResult = userUrlsQueryConditions.validate(queryConditions)
if (validationResult.error) {
res.badRequest(validationResult.error.message)
res.badRequest(jsonMessage(validationResult.error.message))
return
}
// Find user and paginated urls
Expand All @@ -201,7 +201,7 @@ export class UserController {
return
} catch (error) {
if (error instanceof NotFoundError) {
res.notFound(error.message)
res.notFound(jsonMessage(error.message))
return
}
res.serverError(jsonMessage('Error retrieving URLs for user'))
Expand Down Expand Up @@ -253,7 +253,7 @@ export class UserController {
const queryConditions = { searchText, userId, limit }
const validationResult = userTagsQueryConditions.validate(queryConditions)
if (validationResult.error) {
res.badRequest(validationResult.error.message)
res.badRequest(jsonMessage(validationResult.error.message))
return
}
try {
Expand All @@ -264,7 +264,7 @@ export class UserController {
return
} catch (error) {
if (error instanceof NotFoundError) {
res.notFound(error.message)
res.notFound(jsonMessage(error.message))
return
}
res.serverError(jsonMessage('Error retrieving Tags for user'))
Expand Down

0 comments on commit 9a9b8f9

Please sign in to comment.