]> PHS Git Server - phs-api.git/commitdiff
Adding FailedToCreateError to model.js.
authorcharleswrayjr <charleswrayjr@gmail.com>
Fri, 12 Sep 2025 01:55:13 +0000 (20:55 -0500)
committercharleswrayjr <charleswrayjr@gmail.com>
Fri, 12 Sep 2025 01:55:13 +0000 (20:55 -0500)
src/models/model.js

index 83f2fad430fcc1c810560d0971f4c4c03f1970b3..e1f77bbf81eae126d9e3da94689de6d2e231458c 100755 (executable)
@@ -4,7 +4,6 @@
 
 const HttpError = require( 'http-errors' );
 
-
 /**
  * Custom error for not found records
  * @extends HttpError
@@ -19,6 +18,20 @@ class NotFoundError extends HttpError {
   };
 }
 
+/**
+ * Custom error for not found records
+ * @extends HttpError
+ */
+class FailedToCreateError extends HttpError {
+  /**
+   * @param {string} message - Error message
+   */
+  constructor( message ) {
+    super( 409, message );
+    this.name = 'FailedToCreateError';
+  };
+}
+
 /**
  * Custom error for validation failures
  * @extends HttpError
@@ -287,4 +300,4 @@ class Model {
   };
 }
 
-module.exports = { Model, NotFoundError, ValidationError };
\ No newline at end of file
+module.exports = { Model, NotFoundError, ValidationError, FailedToCreateError };
\ No newline at end of file