How to change the default error output in restify 7.x?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 144
- Forks
- 30
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 6
Description
I changed the default error output in restify 4.x using the below code
`var restify = require('restify');
var util = require('util');
function ValidationError(message, errors) {
restify.RestError.call(this, {
restCode: 'ValidationError',
statusCode: 400,
message: message,
constructorOpt: ValidationError
});
this.name = 'ValidationError';
this.body.errors = errors; //<---
}
util.inherits(ValidationError, restify.RestError);`
And I got the desired result. Now am in a process of migrating my project to restify 7.x. So I couldn't use the restify.RestError, I have tried 'restify-errors-options' package's subclassing property but it doesn't work for me. I have tried the below code
restifyErrors.makeConstructor('ValidationError', {
restCode: 'ValidationError',
statusCode: 400,
message: message
});
var myErr = new errors.ValidationError( );
And I ended up with the below error
var myErr = new errors.ValidationError(); ^
TypeError: errors.ValidationError is not a constructor
So can anyone suggest a solution for this problem?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the restify 4.x RestError usage in the report with restify 7.x and the restify-errors-options makeConstructor example. Reproduce the errors.ValidationError constructor failure, then document the supported migration path and the expected custom error output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100