Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add links to Errors.md #1326

Merged
merged 4 commits into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ matters to you.
* <a href="https://github.com/fastify/fastify/blob/master/docs/Lifecycle.md"><code><b>Lifecycle</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Reply.md"><code><b>Reply</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Request.md"><code><b>Request</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Error-Handling.md"><code><b>Error Handling</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Errors.md"><code><b>Errors</b></code></a>
cemremengu marked this conversation as resolved.
Show resolved Hide resolved
* <a href="https://github.com/fastify/fastify/blob/master/docs/ContentTypeParser.md"><code><b>Content Type Parser</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Plugins.md"><code><b>Plugins</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Testing.md"><code><b>Testing</b></code></a>
Expand Down
9 changes: 0 additions & 9 deletions docs/Error-Handling.md

This file was deleted.

84 changes: 48 additions & 36 deletions docs/Errors.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,101 @@
<h1 align="center">Fastify</h1>

<a id="fastify-error-codes"></a>
## Fastify Error Codes
<a id="errors"></a>
## Errors

<a id="FST_ERR_CTP_ALREADY_PRESENT"></a>
### FST_ERR_CTP_ALREADY_PRESENT
<a name="error-handling"></a>
### Error Handling

Uncaught errors are likely to cause memory leaks, file descriptor leaks and other major production issues. [Domains](https://nodejs.org/en/docs/guides/domain-postmortem/) were introduced to try fixing this issue, but they did not. Given the fact that it is not possible to process all uncaught errors in a sensible way, the best way to deal with them at the moment is to [crash](https://nodejs.org/api/process.html#process_warning_using_uncaughtexception_correctly). In case of promises, make sure to [handle](https://nodejs.org/dist/latest-v8.x/docs/api/deprecations.html#deprecations_dep0018_unhandled_promise_rejections) errors [correctly](https://github.com/mcollina/make-promises-safe).

Fastify follows an all-or-nothing approach and aims to be lean and optimal as much as possible. Thus, the developer is responsible for making sure that the errors are handled properly. Most of the errors are usually a result of unexpected input data, so we recommend specifying a [JSON.schema validation](https://github.com/fastify/fastify/blob/master/docs/Validation-and-Serialization.md) for your input data.

Note that, while Fastify doesn't catch uncaught errors for you, if routes are declared as `async`, the error will safely be caught by the promise and routed to the default error handler of Fastify for a generic `Internal Server Error` response. For customizing this behaviour, you should use [setErrorHandler](https://github.com/fastify/fastify/blob/master/docs/Server.md#seterrorhandler).

<a name="fastify-error-codes"></a>
### Fastify Error Codes

<a name="FST_ERR_CTP_ALREADY_PRESENT"></a>
#### FST_ERR_CTP_ALREADY_PRESENT

The parser for this content type was already registered.

<a id="FST_ERR_CTP_INVALID_TYPE"></a>
### FST_ERR_CTP_INVALID_TYPE
<a name="FST_ERR_CTP_INVALID_TYPE"></a>
#### FST_ERR_CTP_INVALID_TYPE

The content type should be a string.

<a id="FST_ERR_CTP_EMPTY_TYPE"></a>
### FST_ERR_CTP_EMPTY_TYPE
<a name="FST_ERR_CTP_EMPTY_TYPE"></a>
#### FST_ERR_CTP_EMPTY_TYPE

The content type cannot be an empty string.

<a id="FST_ERR_CTP_INVALID_HANDLER"></a>
### FST_ERR_CTP_INVALID_HANDLER
<a name="FST_ERR_CTP_INVALID_HANDLER"></a>
#### FST_ERR_CTP_INVALID_HANDLER

An invalid handler was passed for the content type.

<a id="FST_ERR_CTP_INVALID_PARSE_TYPE"></a>
### FST_ERR_CTP_INVALID_PARSE_TYPE
<a name="FST_ERR_CTP_INVALID_PARSE_TYPE"></a>
#### FST_ERR_CTP_INVALID_PARSE_TYPE

The provided parse type is not supported. Accepted values are `string` or `buffer`.

<a id="FST_ERR_CTP_BODY_TOO_LARGE"></a>
### FST_ERR_CTP_BODY_TOO_LARGE
<a name="FST_ERR_CTP_BODY_TOO_LARGE"></a>
#### FST_ERR_CTP_BODY_TOO_LARGE

Request body is larger than the provided limit.

<a id="FST_ERR_CTP_INVALID_MEDIA_TYPE"></a>
### FST_ERR_CTP_INVALID_MEDIA_TYPE
<a name="FST_ERR_CTP_INVALID_MEDIA_TYPE"></a>
#### FST_ERR_CTP_INVALID_MEDIA_TYPE

Received media type is not supported (i.e. there is no suitable content-type parser for it).

<a id="FST_ERR_CTP_INVALID_CONTENT_LENGTH"></a>
### FST_ERR_CTP_INVALID_CONTENT_LENGTH
<a name="FST_ERR_CTP_INVALID_CONTENT_LENGTH"></a>
#### FST_ERR_CTP_INVALID_CONTENT_LENGTH

Request body size did not match Content-Length.

<a id="FST_ERR_DEC_ALREADY_PRESENT"></a>
### FST_ERR_DEC_ALREADY_PRESENT
<a name="FST_ERR_DEC_ALREADY_PRESENT"></a>
#### FST_ERR_DEC_ALREADY_PRESENT

A decorator with the same name is already registered.

<a id="FST_ERR_DEC_MISSING_DEPENDENCY"></a>
### FST_ERR_DEC_MISSING_DEPENDENCY
<a name="FST_ERR_DEC_MISSING_DEPENDENCY"></a>
#### FST_ERR_DEC_MISSING_DEPENDENCY

The decorator cannot be registered due to a missing dependency.

<a id="FST_ERR_HOOK_INVALID_TYPE"></a>
### FST_ERR_HOOK_INVALID_TYPE
<a name="FST_ERR_HOOK_INVALID_TYPE"></a>
#### FST_ERR_HOOK_INVALID_TYPE

The hook name must be a string.

<a id="FST_ERR_HOOK_INVALID_HANDLER"></a>
### FST_ERR_HOOK_INVALID_HANDLER
<a name="FST_ERR_HOOK_INVALID_HANDLER"></a>
#### FST_ERR_HOOK_INVALID_HANDLER

The hook callback must be a function.

<a id="FST_ERR_LOG_INVALID_DESTINATION"></a>
### FST_ERR_LOG_INVALID_DESTINATION
<a name="FST_ERR_LOG_INVALID_DESTINATION"></a>
#### FST_ERR_LOG_INVALID_DESTINATION

Logger acceptes either a `'stream'` or a `'file'` as the destination.

<a id="FST_ERR_REP_INVALID_PAYLOAD_TYPE"></a>
### FST_ERR_REP_INVALID_PAYLOAD_TYPE
<a name="FST_ERR_REP_INVALID_PAYLOAD_TYPE"></a>
#### FST_ERR_REP_INVALID_PAYLOAD_TYPE

Reply payload can either be a `string` or a `Buffer`.

<a id="FST_ERR_SCH_MISSING_ID"></a>
### FST_ERR_SCH_MISSING_ID
<a name="FST_ERR_SCH_MISSING_ID"></a>
#### FST_ERR_SCH_MISSING_ID

The schema provided does not have `$id` property.

<a id="FST_ERR_SCH_ALREADY_PRESENT"></a>
### FST_ERR_SCH_ALREADY_PRESENT
<a name="FST_ERR_SCH_ALREADY_PRESENT"></a>
#### FST_ERR_SCH_ALREADY_PRESENT

A schema with the same `$id` already exists.

<a id="FST_ERR_SCH_NOT_PRESENT"></a>
### FST_ERR_SCH_NOT_PRESENT
<a name="FST_ERR_SCH_NOT_PRESENT"></a>
#### FST_ERR_SCH_NOT_PRESENT

No schema with the provided `$id` exists.