How to change the default error output in restify 7.x?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Documentazione
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
Inizia confrontando l’uso di restify 4.x RestError nel report con restify 7.x e l’esempio makeConstructor di restify-errors-options. Riproduci il fallimento del costruttore di errors.ValidationError, quindi documenta il percorso di migrazione supportato e l’output previsto dell’errore personalizzato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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?
- Lingua principale
- JavaScript
- Stelle
- 144
- Fork
- 30
- Merge medio
- 2g 2h
- PR unite (30g)
- 6
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di restify/errors
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
fixed but not yet released
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Tutte le issue di restify/errors
Issue simili
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
babalae/bettergi-scripts-list#3674 ·
-
ecosystem wording
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
matrix-org/matrix.org#3649 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
vadimdemedes/ink#1029 ·
-
code-quality refactoring
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
langchain-ai/deepagents#6450 ·