Errors

Note

Usage on each methods are valid on the premise that the following classes is defined in advance.

# coding: utf-8

from owlmixin import OwlMixin, TOption
from owlmixin.owlcollections import TDict, TList
from owlmixin.owlenum import OwlEnum, OwlObjectEnum


class Animal(OwlObjectEnum):  # pragma: no cover
    DOG = ("dog", {"cry": "bow-wow"})
    CAT = ("cat", {"cry": "mewing"})

    def cry(self):
        return self.object["cry"]


class Color(OwlEnum):  # pragma: no cover
    RED = "red"
    GREEN = "green"
    BLUE = "blue"


class Food(OwlMixin):  # pragma: no cover
    name: str
    names_by_lang: TOption[TDict[str]]


class Human(OwlMixin):  # pragma: no cover
    id: int
    name: str
    favorites: TList[Food]


class Machine(OwlMixin):  # pragma: no cover
    id: int
    name: str


class Japanese(OwlMixin):  # pragma: no cover
    name: str
    language: str = "japanese"

InvalidTypeError

class owlmixin.errors.InvalidTypeError(*, cls, prop: str, value: Any, expected: Sequence[str], actual)[source]
Variables:
  • title (str) – Error title

  • description (str) – Error description

  • cls (str) – Class name

  • prop (str) – Property name

  • value (Any) – Property value

  • expected (List[str]) – Expected types

  • actual (str) – Actual type

add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

UnknownPropertiesError

class owlmixin.errors.UnknownPropertiesError(*, cls, props: List[str])[source]
Variables:
  • title (str) – Error title

  • description (str) – Error description

  • cls (str) – Class name

  • props (List[str]) – Unknown property names

add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

RequiredError

class owlmixin.errors.RequiredError(*, cls, prop: str, type_)[source]
Variables:
  • title (str) – Error title

  • description (str) – Error description

  • cls (str) – Class name

  • prop (str) – Property name

  • type (str) – Property type

add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.