Mserror.NetworkError exception (mscmp_syst_network v0.1.0)

Defines errors and related metadata for MscmpSystNetwork component errors.

Summary

Types

Represents the available Kinds of error allowed by this Error type.

t()

Describes the structure of an error of generated by this exception.

Functions

Creates a new error struct with the given kind, message, and options.

Types

kinds()

@type kinds() :: :invalid_network | :parse

Represents the available Kinds of error allowed by this Error type.

Available Kinds

  • :parse - Indicates that there were problems attempting to parse an IP Address or Network represented as a string.

  • :invalid_network - The value provided does not represent a valid network.

t()

@type t() :: %Mserror.NetworkError{
  __exception__: true,
  __mscomponent__: module(),
  __mserror__: true,
  cause: t() | Exception.t() | term() | nil,
  context: MscmpSystError.Types.Context.t() | nil,
  kind: kinds(),
  message: String.t()
}

Describes the structure of an error of generated by this exception.

The cause attribute allows for errors to be nested.

Attributes

The following attributes are those which are set or modified by the user when working with errors.

  • kind - The kind of error, see kinds/0 for the available Kinds.

  • message - A string describing the error.

  • context - contextual information for better understanding the error. If provided, the context should be of type MscmpSystError.Types.Context.t/0.

  • cause - The cause of the error, which can be an exception, an error tuple, or any other term.

Internal Attributes

These attributes have their values set at compile time and are used internally by the MscmpSystError framework. They are not to be altered by user code. Reading these attributes in user code is safe, however.

  • __mserror__ - Always true, indicates that this error is compatible with the MscmpSystError framework.

  • __mscomponent__ - The component that generated the error.

Functions

new(kind, message, opts \\ [])

@spec new(kind :: kinds(), message :: String.t(), opts :: keyword()) :: t()

Creates a new error struct with the given kind, message, and options.

Parameters

  • kind - The kind of error, see kinds/0 for the available Kinds.

  • message - A string describing the error.

  • opts - A keyword list of additional options.

Options

  • :context - contextual information for better understanding the error. If provided, the context should be of type MscmpSystError.Types.Context.t/0.

  • :cause - The cause of the error, which can be an exception, an error tuple, or any other term.

  • :parse_error - An error result conforming with MscmpSystError.Types.parsable_error/0 to be parsed overriding certain attributes of the exception struct. When provided the message parameter is treated as a default message which can be overridden by a message supplied by the error result provided to this option. The cause attribute of the exception struct will be set to a value derived from this option's value, ignoring the :cause option if provided; typically you would not provide both :parse_error and :cause in the same call to new/3.

Returns

Returns a struct of this error type with the error details.