Contains the common [ErrorKind] trait implemented by all errors in the
cas-rs ecosystem.
All errors that implement this trait can be output to stderr in a
user-friendly way with the Error::report_to_stderr method. The
[ErrorKind] dervie macro is used to implement this trait with a given error
message, help message, note, and labels to apply to spans in the error report.
Example
Here we create a custom error type and derive the [ErrorKind] trait for it.
Expressions in the error message are evaluated at runtime and have access to
&self, allowing you to use the fields of the error type in the message.
use ErrorKind;
use Error;
/// Tried to override a builtin constant.
,
help = "choose a different name for this variable",
note = "builtin constants include: `i`, `e`, `phi`, `pi`, or `tau`",
)]
let error = new;
// print the error to stderr with colors
error.report_to_stderr.unwrap;
// or manually grab the error text (note: there is some trailing whitespace)
let error_str = ;
assert_eq!;