Errors v0.1.0

Source
Why a pattern was refused, and where in it.

RegexErrorKind

pub enum RegexErrorKind: uint8 {
    UnclosedGroup = 1,
    UnopenedGroup = 2,
    UnclosedClass = 3,
    InvalidEscape = 4,
    NothingToRepeat = 5,
    InvalidRange = 6,
    InvalidCount = 7,
    UnknownProperty = 8,
    UnknownFlag = 9,
    InvalidGroupName = 10,
    DuplicateGroupName = 11,
    Unsupported = 12,
    InvalidText = 13,
    TooLarge = 14,
    OutOfMemory = 15
}

What went wrong. Copy.

Source

Cases

NameValueDescription
UnclosedGroup1A ( has no ).
UnopenedGroup2A ) has no (.
UnclosedClass3A [ has no ].
InvalidEscape4A \ is followed by something that is not an escape, or ends the pattern.
NothingToRepeat5A *, +, ? or {n,m} has nothing before it to repeat.
InvalidRange6A class range ends before it starts, as z-a does, or one end of it is a class such as \d.
InvalidCount7A repetition count is over 1000, or its maximum is below its minimum.
UnknownProperty8A \p{...} names a property or category this package does not know.
UnknownFlag9A (?...) holds a flag other than i, m, s and x.
InvalidGroupName10A group name is empty, or holds something other than letters, digits and _, or starts with a digit.
DuplicateGroupName11Two groups have the same name.
Unsupported12The pattern uses lookaround, a backreference or something else that cannot be matched in linear time.
InvalidText13The pattern is not UTF-8 text.
TooLarge14The compiled pattern would be too large, usually from counted repetitions inside each other, or its groups are nested too deeply.
OutOfMemory15The allocator could not supply the storage.

RegexError

pub struct RegexError {
    pub kind: RegexErrorKind;
    pub offset: uint;
}

Why a pattern could not be compiled, and where. Copy.

Source

Fields

NameTypeDescription
kindRegexErrorKindWhat went wrong.
offsetuintThe byte offset in the pattern where it went wrong; zero for failures that have no place, such as running out of memory.

Associated functions

At

pub func At(
    kind: RegexErrorKind,
    offset: uint
) -> RegexError

An error of kind at offset.

NameTypeDescription
kindRegexErrorKindwhat went wrong
offsetuintwhere in the pattern

Returns: the error

Source

OutOfMemory

pub func OutOfMemory() -> RegexError

The error for storage the allocator could not supply.

Returns: the error

Source