Gltf.Error exception (Gltf v0.1.0)

Copy Markdown View Source

Describes a failure to read a glTF asset.

glTF documents reference each other by index — an accessor names a buffer view, which names a buffer — so a broken file usually means one index in that chain is wrong. Errors therefore carry which index of what, since "invalid glTF" is not something anyone can act on.

Summary

Types

What went wrong

t()

Functions

Builds an error.

Types

kind()

@type kind() ::
  :not_gltf
  | :bad_json
  | :bad_glb
  | :unsupported_version
  | :missing
  | :bad_reference
  | :unsupported
  | :buffer_unavailable
  | :truncated

What went wrong:

  • :not_gltf — the input is neither JSON nor a GLB container
  • :bad_json — the JSON document could not be parsed
  • :bad_glb — the binary container is malformed
  • :unsupported_version — the asset declares a version this cannot read
  • :missing — a referenced index or required field is absent
  • :bad_reference — an index points outside its collection
  • :unsupported — a valid construct this library does not implement
  • :buffer_unavailable — buffer data could not be resolved
  • :truncated — a view or accessor reaches past the end of its buffer

t()

@type t() :: %Gltf.Error{
  __exception__: true,
  detail: String.t() | nil,
  index: non_neg_integer() | nil,
  kind: kind(),
  path: String.t() | nil
}

Functions

new(kind, opts \\ [])

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

Builds an error.

:path is the document location in JSON-pointer-ish form ("meshes[0].primitives[1].attributes.POSITION"), which is what makes a report locatable in a file with hundreds of nodes.