TextError enumv0.1.0
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
| Name | Value | Description |
|---|---|---|
InvalidUtf8 | 3 | The bytes are not well-formed UTF-8. |
NotABoundary | 4 | A 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.
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
spec | FormatSpec | what the placeholder asked for |
Returns: success when the whole description was accepted
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.
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
spec | FormatSpec | what the placeholder asked for |
Returns: success when the whole name was accepted