👋
エラー関連
エラー関連
sailsを使用して500エラーを発生させる
500.ejs
res.serverError()
res.view()
res.redirect()
結果
500エラーのページに遷移するためにはsails.resが必要。
例外発生時のイベントハンドラ
process.on('uncaughtException', handleErrors);
引数
- err <Error> : The uncaught exception.
- origin <string> : Indicates if the exception originates from an unhandled rejection or from a synchronous error. Can either be 'uncaughtException' or 'unhandledRejection'. The latter is used when an exception happens in a Promise based async context (or if a Promise is rejected) and --unhandled-rejections flag set to strict or throw (which is the default) and the rejection is not handled, or when a rejection happens during the command line entry point's ES module static loading phase.
process.on('unhandledRejection', handleErrors);
引数
- reason <Error> | <any> : The object with which the promise was rejected (typically an Error object).
- promise <Promise> : The rejected promise.
参考サイト
- https://itecnote.com/tecnote/error-handling-in-sails-js/
- https://zenn.dev/kimamula/articles/b32d11d52c2b7a733119
- https://github.com/nodejs/node-v0.x-archive/issues/2582
- https://stackoverflow.com/questions/35337411/prevent-sails-js-from-handling-errors
- https://qiita.com/103ma2/items/9cfab6604f813720d482
- https://nodejs.org/api/process.html
Discussion