The Error Unit

libflitter/errors/ErrorUnit

exports:  class ErrorUnit

class ErrorUnit

extends:  libflitter/Unit

Creates a catch-all route for HTTP 404 errors and creates a handler for errors in the underlying Express installation.

go(express app, function next)

overrides:  super.go()         returns:  undefined

Creates a catch-all handler that is called if no other route handler is found. This handles HTTP 404 errors by creating a new Error with status=404. Then, creates an Express handler that, if passed any kind of error, returns the view in the views/errors/ directory with the corresponding status code as its name. If the config value server.environment is development, then all errors render the views/errors/development.pug view. All error views are passed the error object as error.

Error Context

This context guarantees that non-existent routes will be handled as 404 errors, and that all errors will return some error view which is passed the error instance.

No Comments
Back to top