Skip to content

Commit

Permalink
chore: refactor Error-typings and tests (#4824)
Browse files Browse the repository at this point in the history
* Added FST_ERR_VALIDATION to errors.d.ts

The error code FST_ERR_VALIDATION is used as an error code in lib/context.js

* add unit tests, fix FST_ERR_ROUTE_REWRITE_NOT_STR

* add typings

---------

Co-authored-by: Manuel Spigolon <behemoth89@gmail.com>
Co-authored-by: Uzlopak <aras.abbasi@googlemail.com>
  • Loading branch information
3 people committed Jul 8, 2023
1 parent 9f00563 commit 16809b7
Show file tree
Hide file tree
Showing 5 changed files with 929 additions and 24 deletions.
6 changes: 6 additions & 0 deletions docs/Reference/Errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,9 @@ Plugin did not start in time. Default timeout (in millis): `10000`
#### FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE

The decorator is not present in the instance.

<a name="FST_ERR_VALIDATION"></a>

#### FST_ERR_VALIDATION

The Request failed the payload validation.
7 changes: 6 additions & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const codes = {
'Version constraint should be a string.',
500
),
FST_ERR_VALIDATION: createError(
'FST_ERR_VALIDATION',
'%s',
400
),

/**
* ContentTypeParser
Expand Down Expand Up @@ -358,7 +363,7 @@ const codes = {
TypeError
),
FST_ERR_ROUTE_REWRITE_NOT_STR: createError(
'FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT',
'FST_ERR_ROUTE_REWRITE_NOT_STR',
'Rewrite url for "%s" needs to be of type "string" but received "%s"',
500
),
Expand Down

0 comments on commit 16809b7

Please sign in to comment.