View Source CoseDellaVitaEx.Types.ErrorTypes (CoseDellaVitaEx v0.3.0)
Error types. When implemented, makes it possible for clients to query what exactly went wrong
Link to this section Summary
Functions
Translate changeset errors into CoseDellaVitaEx.Errors.*
structs that are translated into specific, typed GraphQL data-errors.
Resolve the type of an "object to identify" (a map or a struct) (that is expected to be an error). The object to identify must either
Same as resolve_error_type/2
but the resolved type must be in the allowlist or be downgraded to :generic_error. A warning about the downgrade is logged.
Link to this section Functions
@spec graphql_changeset_error_traverser( {binary(), keyword() | map()}, (String.t(), map() -> struct()) ) :: struct()
Translate changeset errors into CoseDellaVitaEx.Errors.*
structs that are translated into specific, typed GraphQL data-errors.
examples-doctests
Examples / doctests
Resolve the type of an "object to identify" (a map or a struct) (that is expected to be an error). The object to identify must either:
- define an
:error_type
atom that matches a specific Absinthe object type - have a
:path
and:message
to be identified as a:generic_error
type
## Examples / doctests
iex> resolve_error_type(%{error_type: :bicycle_error}, nil)
:bicycle_error
iex> resolve_error_type(%{path: ["name"], message: "this is a stupid name"}, nil)
:generic_error
iex> resolve_error_type("anything else", nil)
nil
Same as resolve_error_type/2
but the resolved type must be in the allowlist or be downgraded to :generic_error. A warning about the downgrade is logged.
examples-doctests
Examples / doctests
iex> resolve_error_type(%{error_type: :bicycle_error}, nil, [:some_other_error])
:generic_error
iex> resolve_error_type(%{error_type: :bicycle_error}, nil, [:bicycle_error])
:bicycle_error