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.
package/README.md CHANGED
@@ -143,8 +143,8 @@ Use the application generator tool, `express-sweet-generator`, to quickly create
143
143
  │ ├── config.js
144
144
  │ ├── database.js
145
145
  │ └── view.js
146
- ├── exceptions
147
- │ └── UserNotFound.js
146
+ ├── errors
147
+ │ └── NotFoundError.js
148
148
  ├── models
149
149
  │ ├── BookModel.js
150
150
  │ ├── CommentModel.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-sweet-generator",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "EXPRESS SWEET application generator.",
5
5
  "main": "bin/express-sweet-cli.js",
6
6
  "files": [
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Custom error class for "Not Found" errors.
3
+ */
4
+ module.exports = class extends Error {
5
+ /**
6
+ * Creates a new NotFoundError instance.
7
+ * @param {string} [message='The requested record could not be found.'] - The error message.
8
+ */
9
+ constructor(message = 'The requested record could not be found.') {
10
+ super(message);
11
+ this.name = 'NotFoundError';
12
+ this.statusCode = 404; // HTTP status code for "Not Found"
13
+ }
14
+ }
@@ -1,6 +1,6 @@
1
1
  const expressExtension = require('express-sweet');
2
2
  const {Media} = require('nodejs-shared');
3
- const UserNotFound = require('../exceptions/UserNotFound');
3
+ const NotFoundError = require('../errors/NotFoundError');
4
4
 
5
5
  module.exports = class extends expressExtension.database.Model {
6
6
  static get table() {
@@ -123,7 +123,7 @@ module.exports = class extends expressExtension.database.Model {
123
123
  }, set);
124
124
  const user = await this.getUser(userId);
125
125
  if (!user)
126
- throw new UserNotFound();
126
+ throw new NotFoundError();
127
127
  transaction = await super.begin();
128
128
  user.email = set.email;
129
129
  user.name = set.name;