Dmn.Error exception (dmn v0.1.0)

Copy Markdown View Source

What is wrong with a model, as a value.

Nothing in dmn raises for the input it is given: a document that is not XML, a model that breaks the schema, an import that cannot be found, an expression that does not parse, all come back as {:error, %Dmn.Error{}}. It is an exception too, so Dmn.load!/2 and the like can raise it.

FieldIs
kind:xml (the bytes are not a usable XML document), :model (the document is not a DMN model), :import (an import cannot be had), :compile (the model cannot be compiled), :run (a run cannot be done, or ended in :strict mode), :limit (a bound of Dmn.Limits is passed)
codean atom that says what, for a program to match on
messagethe text, for a person
elementthe id of the element of the model that it is about, if it has one
linethe line of the document, for :xml and :model
detailswhatever else is known (the name, the limit, the value)

Summary

Types

kind()

@type kind() :: :xml | :model | :import | :compile | :run | :limit

t()

@type t() :: %Dmn.Error{
  __exception__: term(),
  code: atom(),
  details: map(),
  element: String.t() | nil,
  kind: kind(),
  line: pos_integer() | nil,
  message: String.t()
}

Functions

new(kind, code, message, fields \\ [])

@spec new(kind(), atom(), String.t(), keyword()) :: t()

Makes an error.

iex> error = Dmn.Error.new(:xml, :doctype_not_allowed, "a DOCTYPE is not read", line: 1)
iex> {error.kind, error.code, error.line}
{:xml, :doctype_not_allowed, 1}