SimdJson.Error exception (SimdJson v1.0.0)

View Source

A stable, redacted error returned by SimdJson operations.

Callers should branch on reason; message is explanatory and may evolve. byte_offset, when present, is relative to the logical input rather than its native padded allocation. native_code is diagnostic only. path, when present, is copied from a validated caller projection. array_index, when present, is a checked zero-based source-array index. Inspection omits the message and path contents and bounds numeric metadata so accidentally forged or enriched text is not logged by default.

iex> {:error, error} = SimdJson.open("?")
iex> error.reason
:invalid_json
iex> inspect(error) =~ "reason: :invalid_json"
true
iex> inspect(error) =~ error.message
false

iex> {:error, error} = SimdJson.select(~s({"ready":true}), value: ["value"])
iex> {error.reason, error.path}
{:no_such_field, ["value"]}
iex> inspect(error) =~ "value"
false

Summary

Types

reason()

@type reason() ::
  :invalid_json
  | :invalid_utf8
  | :unexpected_eof
  | :out_of_memory
  | :file_not_found
  | :file_unreadable
  | :not_regular_file
  | :file_changed
  | :closed
  | :not_owner
  | :invalid_projection
  | :no_such_field
  | :index_out_of_bounds
  | :incorrect_type
  | :number_out_of_range
  | :max_depth_exceeded
  | :input_too_large
  | :container_too_large
  | :string_too_large
  | :output_too_large
  | :batch_too_large
  | :busy
  | :cursor_consumed
  | :cancelled
  | :native_failure

t()

@type t() :: %SimdJson.Error{
  __exception__: true,
  array_index: non_neg_integer() | nil,
  byte_offset: non_neg_integer() | nil,
  message: String.t(),
  native_code: integer() | nil,
  path: [binary() | 0..18_446_744_073_709_551_615, ...] | nil,
  reason: reason()
}