Standardize route error handling to use createExpressError
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript
- Ambito
- backend
Direzione di ricerca
Inizia da rest.js per esaminare il pattern esistente di utils.createExpressError, quindi cerca nei file delle route gli handler POST che assegnano statusMessage o statusCode a res prima di chiamare next(res). Sostituisci ogni percorso di errore corrispondente con il pattern standard dell’oggetto errore e conferma che tutti questi handler ora passino gli errori creati a next().
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
The POST handlers in the route files use an unconventional pattern of passing the res object directly to next() as the error argument:
res.statusMessage = 'Improper request method for updating, please use PATCH to add new keys to this object.'
res.status(405)
next(res)
This works because rest.messenger reads err.statusMessage and err.statusCode from whatever object is passed, and the res object happens to have those properties. However, it creates a confusing situation where err === res inside the error handler.
The rest of the codebase uses next(utils.createExpressError({...})) for error handling (see rest.js), which is the standard Express convention.
Standardize these routes to use the same createExpressError pattern as the rest of the codebase:
if (!rest.checkPatchOverrideSupport(req, res)) {
return next(utils.createExpressError({
statusCode: 405,
statusMessage: 'Improper request method for updating, please use PATCH to add new keys to this object.'
}))
}
controller.patchSet(req, res, next)
Context
Found during static review of #206. Out of scope for that PR since it's a pre-existing pattern.
- Lingua principale
- JavaScript
- Stelle
- 3
- Fork
- 6
- Merge medio
- 4g 9h
- PR unite (30g)
- 5
Preparare l'ambiente
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 CenterForDigitalHumanities/rerum_server_nodejs
-
bug documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
backend dependencies easy
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
CenterForDigitalHumanities/rerum_server_nodejs#290 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 74/100
Tutte le issue di CenterForDigitalHumanities/rerum_server_nodejs
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
solana-foundation/solana-com#2202 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
yegor256/copyrights-action#216 ·
-
[BUG] onScroll never refreshes the window container's height after a vertical-only viewport resizeAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
juliangarnier/anime#1192 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
PedestrianDynamics/pyFDS-Evac#226 ·
I maintainer di solito rispondono entro 1 giorno