express-sweet-generator 2.0.6 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import * as expressExtension from 'express-sweet';
2
2
  import {Router} from 'express';
3
3
  import {query, body, validationResult} from 'express-validator';
4
4
  import UserModel from '../../models/UserModel.js';
5
- import UserNotFound from '../../exceptions/UserNotFound.js';
5
+ import NotFoundError from '../../errors/NotFoundError.js';
6
6
  import * as CustomValidation from '../../shared/CustomValidation.js';
7
7
 
8
8
  const router = Router();
@@ -81,7 +81,7 @@ router.put('/:userId(\\d+)', [
81
81
  await UserModel.updateUser(req.params.userId, req.body.user);
82
82
  res.json(true);
83
83
  } catch (error) {
84
- if (error instanceof UserNotFound)
84
+ if (error instanceof NotFoundError)
85
85
  res.json({error: error.name});
86
86
  else
87
87
  next(error);
@@ -106,7 +106,7 @@ router.put('/profile', [
106
106
  await UserModel.updateUser(req.user.id, req.body.user);
107
107
  res.json(true);
108
108
  } catch (error) {
109
- if (error instanceof UserNotFound)
109
+ if (error instanceof NotFoundError)
110
110
  res.json({error: error.name});
111
111
  else
112
112
  next(error);
@@ -1,6 +0,0 @@
1
- module.exports = class extends Error {
2
- constructor() {
3
- super('User not found');
4
- this.name = 'UserNotFound';
5
- }
6
- }
@@ -1,6 +0,0 @@
1
- export default class extends Error {
2
- constructor() {
3
- super('User not found');
4
- this.name = 'UserNotFound';
5
- }
6
- }