Skip to main content

Code

Type Alias Code 

Source
pub type Code = u32;
Expand description

Error codes for the parser.

Codes are grouped by their type. The first byte of the code indicates the type of the error. The second byte indicates the category of the error. The codes from 0x0000_0000 to 0x0000_ffff are reserved for the core library. The codes from 0x8000_0000 to 0xffff_ffff are reserved for custom errors.

These codes are used to identify the error in the ParseError and to provide a unique method to identify the error. This is a convenient way to handle errors in a programmatic way. Custom parsers can use the custom error codes to identify their errors. But they can also use the core error codes if they want to or omit the error code completely and only use the error message with an error code of ERR_CUSTOM.

An important error code is ERR_EOF. It is used to indicate an unexpected end of file and can be used to determine if more input is required to parse the input.