Search documentation of snmpkit

# SnmpKit.SnmpLib.MIB.Error (snmpkit v1.2.0)

Enhanced error handling with recovery and detailed diagnostics.

Provides structured error reporting with context, suggestions, and precise location information for MIB compilation errors.

# Summary

## Types

error_type()
t()

## Functions

format(error, opts \\ [])

Format an error for display with optional color coding.

new(type, opts \\ [])

Create a new error with detailed context and suggestions.

# Types

# error_type()

    @type error_type() ::
      :syntax_error
      | :semantic_error
      | :import_error
      | :type_error
      | :constraint_error
      | :duplicate_definition
      | :file_not_found
      | :unterminated_string
      | :unexpected_token
      | :unexpected_eof
      | :invalid_number
      | :invalid_identifier

# t()

    @type t() :: %SnmpKit.SnmpLib.MIB.Error{
      column: integer() | nil,
      context: map(),
      line: integer() | nil,
      message: binary(),
      suggestions: [binary()],
      type: error_type()
    }

# Functions

# format(error, opts \\ [])

    @spec format(
      t(),
      keyword()
    ) :: binary()

Format an error for display with optional color coding.

## Examples

    iex> error = SnmpKit.SnmpLib.MIB.Error.new(:syntax_error, line: 42, column: 10)
    iex> SnmpKit.SnmpLib.MIB.Error.format(error)
    "Error at line 42, column 10: Syntax error"

# new(type, opts \\ [])

    @spec new(
      error_type(),
      keyword()
    ) :: t()

Create a new error with detailed context and suggestions.

## Examples

    iex> SnmpKit.SnmpLib.MIB.Error.new(:unexpected_token,
    ...>   expected: :max_access,
    ...>   actual: :access,
    ...>   line: 42,
    ...>   column: 10
    ...> )
    %SnmpKit.SnmpLib.MIB.Error{
      type: :unexpected_token,
      message: "Expected max_access, but found access",
      suggestions: ["Did you mean 'MAX-ACCESS' instead of 'ACCESS'?"]
    }