Search results

There are no results.

std.json.Error

class pub Error

A type describing an error produced while parsing a JSON document.

Fields

kind

let pub @kind: ErrorKind

A value describing the kind of error.

offset

let pub @offset: Int

The byte offset in the input string at which the error starts.

Managing column counts is tricky, as this involves maintaining a grapheme cluster counter, which is complicated and expensive. Instead we report a byte offset (relative to the start of the input), as we need to maintain this anyway.

The article at https://www.foonathan.net/2021/02/column/ contains additional information regarding this topic.

Static methods

generic

Show source code
Hide source code
fn pub static generic(message: String, offset: Int) -> Error {
  Error(kind: ErrorKind.Generic(message), offset: offset)
}
fn pub static generic(message: String, offset: Int) -> Error

Returns a generic error with the given message and offset.

Instance methods

!=

Show source code
Hide source code
fn pub !=(other: T) -> Bool {
  (self == other).false?
}
fn pub !=(other: T) -> Bool

Returns true if self and the given object are not equal to each other.

==

Show source code
Hide source code
fn pub ==(other: ref Error) -> Bool {
  @kind == other.kind and @offset == other.offset
}
fn pub ==(other: ref Error) -> Bool

Returns true if self and the given object are equal to each other.

This operator is used to perform structural equality. This means two objects residing in different memory locations may be considered equal, provided their structure is equal. For example, two different arrays may be considered to have structural equality if they contain the exact same values.

fmt

Show source code
Hide source code
fn pub fmt(formatter: mut Formatter) {
  formatter
    .object('Error')
    .field('kind', @kind)
    .field('offset', @offset)
    .finish
}
fn pub fmt(formatter: mut Formatter)

Formats self in a human-readable format for debugging purposes.

to_string

Show source code
Hide source code
fn pub to_string -> String {
  '${@kind}, at byte offset ${@offset}'
}
fn pub to_string -> String

Converts self to a String.

Implemented traits

std.cmp.

Equal

impl Equal[ref Error] for Error
std.fmt.

Format

impl Format for Error
std.string.

ToString

impl ToString for Error