Errors v0.1.0
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.
Cases
| Name | Value | Description |
|---|---|---|
UnclosedGroup | 1 | A ( has no ). |
UnopenedGroup | 2 | A ) has no (. |
UnclosedClass | 3 | A [ has no ]. |
InvalidEscape | 4 | A \ is followed by something that is not an escape, or ends the pattern. |
NothingToRepeat | 5 | A *, +, ? or {n,m} has nothing before it to repeat. |
InvalidRange | 6 | A class range ends before it starts, as z-a does, or one end of it is a class such as \d. |
InvalidCount | 7 | A repetition count is over 1000, or its maximum is below its minimum. |
UnknownProperty | 8 | A \p{...} names a property or category this package does not know. |
UnknownFlag | 9 | A (?...) holds a flag other than i, m, s and x. |
InvalidGroupName | 10 | A group name is empty, or holds something other than letters, digits and _, or starts with a digit. |
DuplicateGroupName | 11 | Two groups have the same name. |
Unsupported | 12 | The pattern uses lookaround, a backreference or something else that cannot be matched in linear time. |
InvalidText | 13 | The pattern is not UTF-8 text. |
TooLarge | 14 | The compiled pattern would be too large, usually from counted repetitions inside each other, or its groups are nested too deeply. |
OutOfMemory | 15 | The 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.
Fields
| Name | Type | Description |
|---|---|---|
kind | RegexErrorKind | What went wrong. |
offset | uint | The 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.
| Name | Type | Description |
|---|---|---|
kind | RegexErrorKind | what went wrong |
offset | uint | where in the pattern |
Returns: the error
OutOfMemory
pub func OutOfMemory() -> RegexError
The error for storage the allocator could not supply.
Returns: the error