Global

Type Definitions

CaseParserType

Source:
Properties:
Name Type Description
map boolean

Whether or not the parser is an object map.

function boolean

Whether or not the parser is a function.

A simple object to check what kind of parser it's.

Type:

Condition

Source:
Type:

ErrorCaseDefinition

Source:
Properties:
Name Type Attributes Description
name string

The name of the case.

message ErrorCaseDefinition | string

The formatted message or the function that generates one.

condition RegExp | string

A string or a expression to match against an error that could be parsed.

parsers Object.<string, ParserLike> <nullable>

A map of reusable parsers. Each parser can be an object map, a function or an instance of CaseParser.

parse InstructionListLike <nullable>

A list of parsers the case should use on extracted parameters. Each item of the list can be either the name of a parser defined on parsers, the name of a parser on the scope, a function to parse a value, or an array of all the thing previously mentioned.

useOriginal boolean <nullable>

Whether or not the case should use the original message when matched.

The required properties to create a new ErrorCase.

Type:

ErrorCaseMessage() → {string}

Source:

A function that generates a formatted message for an error.

Returns:
Type
string

ErrorCaseOptions

Source:
Properties:
Name Type Description
CaseParserClass Class.<CaseParser>

The class to be used to create a parser.

FormattedErrorClass Class.<FormattedError>

The class to be used to create a custom error after a message is parsed.

The options to customize how the class behaves.

Type:

Instruction

Source:
Type:

InstructionFn(value) → {*}

Source:
Parameters:
Name Type Description
value *

The value captured from the error that needs to formatted.

Returns:
Type
*

InstructionListLike

Source:
Type:

ParserLike()

Source:

ParserrorErrorObject

Source:
Properties:
Name Type Description
message string

The error message.

An object with a signature similar to an Error that Parserror can parse.

Type:

ParserrorOptions

Source:
Properties:
Name Type Description
CaseParserClass Class.<CaseParser>

The class that will be used to create parsers. It will also be sent down to every case that gets created, on its option parameter.

ErrorCaseClass Class.<ErrorCase>

The class that will be used to create cases.

FormattedErrorClass Class.<FormattedError>

The class that will be used to create formatted errors. It will also be sent down to every case that gets created, on its options parameter.

ScopeClass Class.<Scope>

The class that will be used to create scopes.

errorContextProperties Array.<string>

A list of properties the class will try to find on given errors in order to use as context information for ErrorCase and FormattedError.

The options to customize how the class behaves.

Type:

ParserrorParseOptions

Source:
Properties:
Name Type Attributes Description
cases Array.<string>

A list of specific cases it should validated against.

scopes Array.<string>

A list of specific scopes it should use to valdiate the error.

fallback string <nullable>

A fallback message in case the error can't be parsed. If not specified, the returned error will maintain the original message.

The options that can be used to customize how Parserror#parse works.

Type:

ParserrorWrapper(error, fallbackopt, nullable) → {FormattedError}

Source:

A pre configured parser to format errors with specific cases and/or scopes.

Parameters:
Name Type Attributes Default Description
error Error | string | ParserrorErrorObject

The error to parse.

fallback string <optional>
<nullable>
null

A fallback message in case the error can't be parsed. If not specified, the returned error will maintain the original message.

Returns:
Type
FormattedError