Module orca_whirlpool.internal.invariant

Expand source code
# https://github.com/alexreardon/tiny-invariant/blob/master/src/tiny-invariant.ts

PREFIX = "Invariant failed"


class InvaliantFailedError(Exception):
    pass


def invariant(condition, message: str = None):
    if condition:
        return
    value = PREFIX if message is None else "{}: {}".format(PREFIX, message)
    raise InvaliantFailedError(value)

def unreachable(message: str = None):
    invariant(False, message)

Functions

def invariant(condition, message: str = None)
Expand source code
def invariant(condition, message: str = None):
    if condition:
        return
    value = PREFIX if message is None else "{}: {}".format(PREFIX, message)
    raise InvaliantFailedError(value)
def unreachable(message: str = None)
Expand source code
def unreachable(message: str = None):
    invariant(False, message)

Classes

class InvaliantFailedError (*args, **kwargs)

Common base class for all non-exit exceptions.

Expand source code
class InvaliantFailedError(Exception):
    pass

Ancestors

  • builtins.Exception
  • builtins.BaseException