Exceptions (yombo.core.exceptions)

Create various exceptions to be used throughout the Yombo gateway.

Module author: Mitch Schwenk <mitch-gw@yombo.net>

copyright

Copyright 2012-2020 by Yombo.

license

LICENSE for details.

view-source

View Source Code

exception yombo.core.exceptions.YomboException(errors, error_code=101, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]

Extends Exception - A non-fatal generic gateway exception that is used for minor errors.

Accepts a list of errors and will generate both text mesasge and html output. The raw error will also be made available.

The meta variable is a dict to provide any additional details about the error.

__init__(errors, error_code=101, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]
Parameters
  • errors (Union[str, dict, List[Dict[str, Union[str, int, dict]]]]) – List of errors with additional details. Can be used by others to format more detailed responses.

  • error_code (Union[str, int, None]) – The error number to log/display.

  • component_name (Optional[str]) – Name of the library, component, or module raising the exception.

  • component_type (Optional[str]) – Library, core, module, etc.

  • component_function (Optional[str]) – Name of the function that raised the error.

  • meta (dict) – Any additional items for reference.

  • title (Optional[str]) – Use a default title for errors.

  • response_code (Optional[int]) – Response code to send to the web browser.

response_code: int
errors: Union[str, List[Dict[str, Union[str, int, dict]]]]
message: str = ''
html: str = ''
error_code: Union[str, int]
component_name: str
component_type: str
component_function: str
__str__()[source]

Formats the exception for logging to text.

Returns

A formatted string of the error message.

Return type

string

__annotations__ = {'component_function': <class 'str'>, 'component_name': <class 'str'>, 'component_type': <class 'str'>, 'error_code': typing.Union[str, int], 'errors': typing.Union[str, typing.List[typing.Dict[str, typing.Union[str, int, dict]]]], 'html': <class 'str'>, 'links': <class 'dict'>, 'message': <class 'str'>, 'response_code': <class 'int'>}
__module__ = 'yombo.core.exceptions'
__weakref__

list of weak references to the object (if defined)

exception yombo.core.exceptions.YomboWarning(errors, error_code=102, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]

Extends Exception - A non-fatal warning gateway exception that is used for items needing user attention.

__init__(errors, error_code=102, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]

Setup the YomboWarning and then pass everying to YomboException

Parameters
  • errors (Union[str, dict, List[Dict[str, Union[str, int]]]]) – List of errors with additional details. Can be used by others to format more detailed responses.

  • error_code (Union[str, int, None]) – The error number to log/display.

  • component_name (Optional[str]) – Name of the library, component, or module raising the exception.

  • component_type (Optional[str]) – Library, core, module, etc.

  • component_function (Optional[str]) – Name of the function that raised the error.

  • meta (Optional[dict]) – Any additional items for reference.

  • title (Optional[str]) – Use a default title for errors.

  • response_code (Optional[int]) – Response code to send to the web browser.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.IntentError(errors, error_code=102, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]

Base class for intent related errors.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.IntentHandleError(errors, error_code=102, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]

Error while handling intent.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.IntentUnexpectedError(errors, error_code=102, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]

Unexpected error while handling intent.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.UnknownIntent(errors, error_code=1359, component_name=None, component_type=None, component_function=None, meta=None)[source]

When the intent is not registered.

__init__(errors, error_code=1359, component_name=None, component_type=None, component_function=None, meta=None)[source]

Setup the YomboWarning and then pass everying to YomboException

Parameters
  • errors (Union[str, List[Dict[str, Union[str, int]]]]) – List of errors with additional details. Can be used by others to format more detailed responses.

  • error_code (Union[str, int, None]) – The error number to log/display.

  • component_name (Optional[str]) – Name of the library, component, or module raising the exception.

  • component_type (Optional[str]) – Library, core, module, etc.

  • component_function (Optional[str]) – Name of the function that raised the error.

  • meta (Optional[dict]) – Any additional items for reference.

  • title – Use a default title for errors.

  • response_code – Response code to send to the web browser.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.InvalidSlotInfo(errors, error_code=102, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]

When the slot data is invalid or missing components.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.YomboMarshmallowValidationError(validation_error, error_code=101, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]

Takes a Marshmallow ValidationError and converts to Yombo format.

__init__(validation_error, error_code=101, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]
Parameters
  • errors – List of errors with additional details. Can be used by others to format more detailed responses.

  • error_code (Union[str, int, None]) – The error number to log/display.

  • component_name (Optional[str]) – Name of the library, component, or module raising the exception.

  • component_type (Optional[str]) – Library, core, module, etc.

  • component_function (Optional[str]) – Name of the function that raised the error.

  • meta (dict) – Any additional items for reference.

  • title (Optional[str]) – Use a default title for errors.

  • response_code (Optional[int]) – Response code to send to the web browser.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.YomboInvalidValidation(errors, error_code=1873, component_name=None, component_type=None, component_function=None, meta=None)[source]

Occurs when asked to validate something and it fails. Primary use cases are: 1) validating user inputs to the web interface, or 2) validating variable types within the framework or modules.

__init__(errors, error_code=1873, component_name=None, component_type=None, component_function=None, meta=None)[source]

Setup the YomboWarning and then pass everying to YomboException

Parameters
  • errors (Union[str, List[Dict[str, Union[str, int]]]]) – List of errors with additional details. Can be used by others to format more detailed responses.

  • error_code (Union[str, int, None]) – The error number to log/display.

  • component_name (Optional[str]) – Name of the library, component, or module raising the exception.

  • component_type (Optional[str]) – Library, core, module, etc.

  • component_function (Optional[str]) – Name of the function that raised the error.

  • meta (Optional[dict]) – Any additional items for reference.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.YomboWebinterfaceError(errors=None, error_code='error_3102', title=None, links=None, response_code=None, component_name=None, component_type=None, component_function=None, meta=None)[source]

Raised when somewhere within the webinterface. Collects various items to be displayed via template or to output in JSON/MSGPACK.

__init__(errors=None, error_code='error_3102', title=None, links=None, response_code=None, component_name=None, component_type=None, component_function=None, meta=None)[source]

Setup the YomboWarning and then pass everying to YomboException

Parameters
  • errors (Union[str, List[Dict[str, Union[str, int]]], None]) – List of errors with additional details. Can be used by others to format more detailed responses.

  • error_code (Union[str, int, None]) – The error number to log/display.

  • component_name (Optional[str]) – Name of the library, component, or module raising the exception.

  • component_type (Optional[str]) – Library, core, module, etc.

  • component_function (Optional[str]) – Name of the function that raised the error.

  • meta (Optional[dict]) – Any additional items for reference.

response_code
__module__ = 'yombo.core.exceptions'
errors
error_code
component_name
component_type
component_function
exception yombo.core.exceptions.YomboInvalidArgument[source]

Raised when an argument to a function is invalid.

__module__ = 'yombo.core.exceptions'
__weakref__

list of weak references to the object (if defined)

exception yombo.core.exceptions.YomboAPICredentials(errors, error_code=9854, component_name=None, component_type=None, component_function=None, meta=None)[source]

Extends YomboException - A non-fatal warning gateway exception that is used when the YomboAPI library ran into an authentication issue and cannot process the request.

__init__(errors, error_code=9854, component_name=None, component_type=None, component_function=None, meta=None)[source]

Setup the YomboWarning and then pass everything to YomboException

Parameters
  • errors (Union[str, List[Dict[str, Union[str, int]]]]) – List of errors with additional details. Can be used by others to format more detailed responses.

  • error_code (Union[str, int, None]) – The error number to log/display.

  • component_name (Optional[str]) – Name of the library, component, or module raising the exception.

  • component_type (Optional[str]) – Library, core, module, etc.

  • component_function (Optional[str]) – Name of the function that raised the error.

  • meta (Optional[dict]) – Any additional items for reference.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.YomboCritical(message)[source]

Extends RuntimeWarning - A fatal error gateway exception - forces the gateway to quit.

Used to exit the gateway with a return status code representing something went wrong.

__init__(message)[source]
Parameters

message (string) – The error message to log/display.

message = ''
__str__()[source]

Formats the exception for logging to text.

@return: A formated string of the error message. @rtype: string

exit()[source]

Exists the daemon with exit status 127 so that the wrapper script knows to restart the gateway.

__module__ = 'yombo.core.exceptions'
__weakref__

list of weak references to the object (if defined)

exception yombo.core.exceptions.YomboQuit(message)[source]

Extends RuntimeWarning - A fatal error gateway exception - forces the gateway to quit.

Used to exit the gateway with a return status code representing everything is good.

__init__(message)[source]
Parameters

message (string) – The error message to log/display.

message = ''
__str__()[source]

Formats the exception for logging to text.

@return: A formated string of the error message. @rtype: string

exit()[source]

Exists the daemon with exit status 127 so that the wrapper script knows to restart the gateway.

__module__ = 'yombo.core.exceptions'
__weakref__

list of weak references to the object (if defined)

exception yombo.core.exceptions.YomboRestart(message)[source]

Extends RunningWarning - Restarts the gateway, not a fatal exception.

__init__(message)[source]
Parameters

message (string) – The error message to log/display.

message = ''
__str__()[source]

Formats the exception for logging to text.

@return: A formated string of the error message. @rtype: string

exit()[source]

Exists the daemon with exit status 127 so that the wrapper script knows to restart the gateway.

__module__ = 'yombo.core.exceptions'
__weakref__

list of weak references to the object (if defined)

exception yombo.core.exceptions.YomboNoAccess(action, platform, item_id, request_by, request_by_type, request_context, error_code=None, message=None, component_name=None, component_type=None, component_function=None, meta=None)[source]

Extends YomboWarning - Resource accessed without required permissions.

__init__(action, platform, item_id, request_by, request_by_type, request_context, error_code=None, message=None, component_name=None, component_type=None, component_function=None, meta=None)[source]

Setup the YomboWarning and then pass everying to YomboException

Parameters
  • action (str) – The action requested, such as edit, view, create, etc.

  • platform (str) – The platform, such as yombo.lib.atoms

  • item_id (Union[str, int]) – The id requested, such as a command_id, device_id.

  • request_by (str) – The id of the requester.

  • request_by_type (str) – The type of requester, such as authkey, user.

  • request_context (str) – Context about the request. Such as an IP address of the source.

  • error_code (Union[str, int, None]) – An error code for the no access, typically the request_id.

  • message (Optional[str]) – Message to return to the requester.

  • component_name (Optional[str]) – Name of the library, component, or module raising the exception.

  • component_type (Optional[str]) – Library, core, module, etc.

  • component_function (Optional[str]) – Name of the function that raised the error.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.YomboFileError(errors, error_code=102, component_name=None, component_type=None, component_function=None, meta=None, title=None, response_code=None)[source]

Extends YomboWarning - A missing configuration or improperly configured option.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
exception yombo.core.exceptions.YomboFuzzySearchError(search_for, key, value, ratio, others)[source]

Extends Exception - A non-fatal FuzzySearch error. Occurs when something happened with a fuzzy search.

Variables
  • device_id – (string) The device_id if known, otherwise will be None.

  • error_code – (int) An error number for further error sorting/handling.

  • key – (string) If from a fuzzy search exception, will be the best possible device_id.

  • others – (dict) If from a fuzzy search exception, will be a dictionary of other alternatives.

  • search_for – (string) If from a fuzzy search exception, will be the requested search key.

  • ratio – (float) If from a fuzzy search exception, the match confidence in percent as .80 for 80%.

  • value – (device) If from a fuzzy search exception, will be the best possible device instance.

__module__ = 'yombo.core.exceptions'
__weakref__

list of weak references to the object (if defined)

__init__(search_for, key, value, ratio, others)[source]
Parameters
  • search_for – The requestd search key.

  • key – The best matching key.

  • value – The best matchin value.

  • ratio – The ratio as a percent of closeness. IE: .32

  • others – Other top 5 choices to choose from.

__str__()[source]

Formats the exception for logging to text.

Returns

A formated string of the error message.

Return type

string

exception yombo.core.exceptions.YomboPinCodeError[source]

Raised when the pin number is invalid.

__module__ = 'yombo.core.exceptions'
__weakref__

list of weak references to the object (if defined)

exception yombo.core.exceptions.YomboCronTabError[source]

Exceptions related to crontab errors.

__module__ = 'yombo.core.exceptions'
__weakref__

list of weak references to the object (if defined)

exception yombo.core.exceptions.YomboHookStopProcessing(message, error_code=19348, component_name=None, component_type=None, component_function=None)[source]

Raise this during a hook call to stop processing any remain hook calls and to stop further processing of the remaining request.

__module__ = 'yombo.core.exceptions'
errors
error_code
response_code
component_name
component_type
component_function
__init__(message, error_code=19348, component_name=None, component_type=None, component_function=None)[source]

Setup the YomboWarning and then pass everying to YomboException

Parameters
  • message (str) – The error message to log/display.

  • error_code (Union[str, int]) – The error number to log/display.

  • component_name (Optional[str]) – Name of the library, component, or module raising the exception.

  • component_type (Optional[str]) – Library, core, module, etc.

  • component_function (Optional[str]) – Name of the function that raised the error.