Sinetex.Error exception (sinetex v0.1.0)

Copy Markdown View Source

A protocol error, as defined by the security error table of the Manual de Segurança do SFN (§5.5.1).

Fields:

  • :c03 - the error code that goes in field C03 of the header (0x01..0x14, or 0xFF).
  • :egen - the matching GEN0004 error code ("EGEN9901".."EGEN9920"), or nil for 0xFF.
  • :field - the header field the error refers to (:c01..:c15, :body), or nil.
  • :message - a short description, in English.
  • :reason - the internal cause, for logs only. It may say more than :c03 does (see the c14_errors: :uniform option of Sinetex.open/2), so do not send it to the counterparty.

The struct is an exception, so it can be raised, but Sinetex functions always return it in an {:error, error} tuple.

Summary

Types

A C03 error code: 0x01..0x14 or 0xFF.

t()

Functions

Returns true if code is a valid, non-zero C03 error code.

All valid C03 error codes, in ascending order.

Builds the error for code, keeping reason for logs.

Types

code()

@type code() :: 1..20 | 255

A C03 error code: 0x01..0x14 or 0xFF.

field()

@type field() ::
  :c01
  | :c02
  | :c04
  | :c06
  | :c07
  | :c08
  | :c09
  | :c10
  | :c11
  | :c12
  | :c13
  | :c14
  | :c15
  | :body
  | nil

t()

@type t() :: %Sinetex.Error{
  __exception__: true,
  c03: code(),
  egen: String.t() | nil,
  field: field(),
  message: String.t(),
  reason: term()
}

Functions

code?(code)

@spec code?(term()) :: boolean()

Returns true if code is a valid, non-zero C03 error code.

codes()

@spec codes() :: [code(), ...]

All valid C03 error codes, in ascending order.

new(code, reason \\ nil)

@spec new(code(), term()) :: t()

Builds the error for code, keeping reason for logs.

iex> error = Sinetex.Error.new(0x0B)
iex> {error.egen, error.field, error.message}
{"EGEN9911", :c15, "invalid signature"}