Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-3d

Source of release 0.9.6

0.9.6 / src / errors.lucb

import interop
import memory

from luce_geocore import geocore

## One identity with luce-geocore's codes, so a failure reads the same whether
## a mesh kernel or the renderer raised it.
pub let invalid: ErrorCode = geocore.invalid
pub let busy: ErrorCode = geocore.busy
pub let limit: ErrorCode = geocore.limit

pub func success[T](value: T) -> interop.Outcome[T]:
    return interop.Outcome[T].success(interop.Owned[T](value))

pub func failure[T](code: ErrorCode, message: str) -> interop.Outcome[T]:
    let copied = interop.copy_text(message) catch exhausted:
        return interop.Outcome[T].failure(memory.exhausted, interop.Owned[str]("out of memory copying a 3D error"))
    return interop.Outcome[T].failure(code, copied)