snowmobile.core.exception_handler

Exception and context management across snowmobile objects.

Module Contents

Classes

ExceptionHandler

All snowmobile classes contain a ExceptionHandler.

class snowmobile.core.exception_handler.ExceptionHandler(within: snowmobile.core.errors.Optional[Any] = None, ctx_id: snowmobile.core.errors.Optional[int] = None, in_context: bool = False, children: snowmobile.core.errors.Dict[int, Any] = None, is_active_parent: bool = False, to_mirror: snowmobile.core.errors.Optional[List[Any]] = None)

Bases: snowmobile.core.Generic

All snowmobile classes contain a ExceptionHandler.

Parameters
  • within (Optional[Any]) – Class for which the ExceptionHandler is intended.

  • ctx_id (Optional[int]) – Context ID; set/unset by methods when entering/exiting certain contexts.

  • in_context (bool) – Class is currently within a specific ctx_id

  • children (Dict[int, Any]) – Attributes of the within class for which the ExceptionHandler should mirror the methods called on the parent class. # TODO: Refactor this out; it’s essentially janky multi inheritance

  • is_active_parent (bool) – The within class is currently enforcing the context rules on its children

  • to_mirror (Optional[List[Any]]) – Methods called in the attr:`within class that should be applied to its children (i.e. set/reset context ID, etc)

property current(self)

All exceptions in the current context.

collect(self, e: Any[snowmobile_errors])

Stores an exception.

property first(self)snowmobile.core.errors.Error

First exception encountered.

property last(self)snowmobile.core.errors.Error

Last exception encountered.

seen(self, from_ctx: snowmobile.core.errors.Optional[int] = None, of_type: snowmobile.core.errors.Optional[Any[snowmobile_errors], List[snowmobile_errors]] = None, to_raise: snowmobile.core.errors.Optional[bool] = None, with_ids: snowmobile.core.errors.Optional[int, List[int], Set[int]] = None, all_time: bool = False)bool

Boolean indicator of if an exception has been seen.

get(self, from_ctx: snowmobile.core.errors.Optional[int] = None, of_type: snowmobile.core.errors.Optional[Any[snowmobile_errors], List[snowmobile_errors]] = None, to_raise: snowmobile.core.errors.Optional[bool] = None, with_ids: snowmobile.core.errors.Optional[int, List[int], Set[int]] = None, all_time: bool = False, last: bool = False, first: bool = False, _raise: bool = False)

Boolean indicator of if an exception has been seen.

property ctx_id(self)

Current context id.

set(self, ctx_id: snowmobile.core.errors.Optional[int] = None, in_context: bool = False, outcome: snowmobile.core.errors.Optional[int] = None)

Set attributes on self.

set_from(self, other: snowmobile.core.exception_handler.ExceptionHandler)snowmobile.core.exception_handler.ExceptionHandler

Updates attributes of self with those from ‘other’.

reset(self, ctx_id: bool = False, in_context: bool = False, outcome: bool = False)snowmobile.core.exception_handler.ExceptionHandler

Resets attributes on self.

property by_tmstmp(self)

All exceptions by timestamp, ordered by most to least recent.