v0.4.0

TextError enumv0.1.0

Source
What went wrong.
pub enum TextError: int32 {
    InvalidUtf8 = 3,
    NotABoundary = 4
}

Every case is a failure. An operation that can fail returns its result, or nothing, and declares throws TextError, so success is the return value rather than a case here.

Cases

NameValueDescription
InvalidUtf83The bytes are not well-formed UTF-8.
NotABoundary4A byte offset that is not where a character starts, and so not a place text may be cut.

Implements Display

TextError conforms to Display.

WriteDisplay

pub func WriteDisplay(
    &self,
    writer: &var TextWriter,
    spec: FormatSpec
) throws FormatError

Writes the description of what went wrong, or no error for success. The words are stable: they end up in logs and issue reports, and changing them later breaks every reader quietly. They are a description and not a parsing contract — a program branches on the case, not the text. Reports whatever the writer reported, and UnsupportedRequest for any style or precision.

NameTypeDescription
writer&var TextWriterthe destination
specFormatSpecwhat the placeholder asked for

Returns: success when the whole description was accepted

Source

Implements Debug

TextError conforms to Debug.

WriteDebug

pub func WriteDebug(
    &self,
    writer: &var TextWriter,
    spec: FormatSpec
) throws FormatError

Names the case, qualified by its type: TextError::InvalidUtf8. Reports whatever the writer reported, and UnsupportedRequest for any style or precision.

NameTypeDescription
writer&var TextWriterthe destination
specFormatSpecwhat the placeholder asked for

Returns: success when the whole name was accepted

Source