不要怂,就是干,撸起袖子干!

Commit 5c46d67b by Kieron Wiltshire Committed by Jan Aagaard Meier

Added the ability to catch invalid scopes (#6177)

* Added the ability to catch invalid scopes

* accidentally removed param
1 parent e0ab06d1
Showing with 17 additions and 1 deletions
...@@ -25,6 +25,22 @@ class BaseError extends Error { ...@@ -25,6 +25,22 @@ class BaseError extends Error {
exports.BaseError = BaseError; exports.BaseError = BaseError;
/** /**
* Scope Error. Thrown when the sequelize cannot query the specified scope.
*
* @param {string} message Error message
*
* @extends BaseError
* @constructor
*/
class SequelizeScopeError extends BaseError {
constructor(parent) {
super(parent);
this.name = 'SequelizeScopeError';
}
}
exports.SequelizeScopeError = SequelizeScopeError;
/**
* Validation Error. Thrown when the sequelize validation has failed. The error contains an `errors` property, * Validation Error. Thrown when the sequelize validation has failed. The error contains an `errors` property,
* which is an array with 1 or more ValidationErrorItems, one for each validation that failed. * which is an array with 1 or more ValidationErrorItems, one for each validation that failed.
* *
......
...@@ -1161,7 +1161,7 @@ class Model { ...@@ -1161,7 +1161,7 @@ class Model {
return objectValue ? objectValue : sourceValue; return objectValue ? objectValue : sourceValue;
}); });
} else { } else {
throw new Error('Invalid scope ' + scopeName + ' called.'); throw new sequelizeErrors.SequelizeScopeError('Invalid scope ' + scopeName + ' called.');
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!