Error<T>
Struct · built-in type
struct Error<T>A value or an error: the result of something that can fail.
Error<int> Parse(string s) { ... return error("not a number"); }
switch (Parse(text)){ case int n: Console.WriteLine(n); break; case error e: Console.WriteLine(e.Message); break;}int n = try Parse(text); // passes an error on to the callererror("message") or error("message", code) makes the error; Error<void> is a result without a value. With an
error enum the codes are typed: IoError<string> is Error<string, IoError> (IoError). See the language guide
(error handling).
Fields
Section titled “Fields”| Name | Description |
|---|---|
Message |
The message of the error. |
Code |
The code of the error (0 if none was given; the value of the error enum for a typed result). |
Message
Section titled “Message”string MessageThe message of the error.
int CodeThe code of the error (0 if none was given; the value of the error enum for a typed result).