Skip to main content

error_type

Macro error_type 

Source
error_type!() { /* proc-macro */ }
Expand description

Define a new layered error type.

§Syntax

$error_type =
    $vis:vis $name:ident {
        $($variant:variant, )*
    }

$variant =
  // Prefix node.
    {
        $($child_variant:variant, )*
    }
  // Leaf node (three forms, just the same as `syn::Variant`).
  | $ident:ident (
        $(
            $field_ty:ty
        ),*
    )
  | $ident:ident {
        $(
            $field_name:ident: $field_ty:ty
        ),*
    }
  | $ident:ident

§Node Attributes

AttributeDescription
#[diag(kind = $kind:lit_str)]$kind is either "error" or "warn". Default is "error".
#[diag(number = $number:lit_int)]$number is the error number suffix.
#[diag(msg = $msg:lit_str)]$msg is the error message.
#[diag(note = $note:lit_str)]$note is an additional note message.
#[diag(help = $help:lit_str)]$help is an additional help message.
#[diag(span_type = $span_type:lit_str)]$span_type is the type of the span. Default is error_enum::SimpleSpan.

§Field Attributes

AttributeDescription
#[diag(span)]Mark this field as the primary span of this error variant.
#[diag(note = $note:lit_str)]$note is an additional note message on the span.
#[diag(help = $help:lit_str)]$help is an additional help message on the span.
#[diag(label = $label:lit_str)]$label is the label message on the span.