-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript instanceof mongoose.Error #11838
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
Comments
IslandRhythms
added
the
typescript
Types or Types-test related issue / Pull Request
label
May 27, 2022
It is a documentation error. You have to check against mongoose.Error.ValidationError |
Accidently closed |
@Uzlopak Maybe I am misunderstanding something, but from code // mongoose\lib\index.js
/**
* The [MongooseError](#error_MongooseError) constructor.
*
* @method Error
* @api public
*/
Mongoose.prototype.Error = require('./error/index'); // mongoose\lib\error\index.js
/**
* MongooseError constructor. MongooseError is the base class for all
* Mongoose-specific errors.
*
* #### Example:
* const Model = mongoose.model('Test', new Schema({ answer: Number }));
* const doc = new Model({ answer: 'not a number' });
* const err = doc.validateSync();
*
* err instanceof mongoose.Error; // true
*
* @constructor Error
* @param {String} msg Error message
* @inherits Error https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
*/
const MongooseError = require('./mongooseError');
module.exports = exports = MongooseError; // mongoose\lib\error\mongooseError.js
class MongooseError extends Error { }
Object.defineProperty(MongooseError.prototype, 'name', {
value: 'MongooseError'
});
module.exports = MongooseError; So shouldn't |
Thanks for the feedback. It should be now fixed in master. |
Closed
@Uzlopak Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Following the example in https://mongoosejs.com/docs/api/error.html#error_Error
I got the error in
err instanceof mongoose.Error
If the current behavior is a bug, please provide the steps to reproduce.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
node 16.14.2
mongoose 6.3.4
The text was updated successfully, but these errors were encountered: