api_error#

API Error functionality.

Module Contents#

Functions#

set_user_sentry_context(→ None)

Set_user_sentry_context.

handle_exception(→ flask.wrappers.Response)

Handles unexpected exceptions.

Attributes#

api_error.api_error_blueprint#
exception api_error.ApiError#

Bases: Exception

ApiError Class to help handle exceptions.

error_code :str#
message :str#
error_line :str =#
error_type :str =#
file_name :str =#
line_number :int = 0#
offset :int = 0#
status_code :int = 400#
tag :str =#
task_data :dict | str | None#
task_id :str =#
task_name :str =#
task_trace :dict | None#
__str__() str#

Instructions to print instance as a string.

classmethod from_task(error_code: str, message: str, task: SpiffWorkflow.task.Task, status_code: int = 400, line_number: int = 0, offset: int = 0, error_type: str = '', error_line: str = '', task_trace: dict | None = None) ApiError#

Constructs an API Error with details pulled from the current task.

static remove_unserializeable_from_dict(my_dict: dict) dict#

Removes unserializeable from dict.

static is_jsonable(x: Any) bool#

Attempts a json.dump on given input and returns false if it cannot.

classmethod from_task_spec(code: str, message: str, task_spec: SpiffWorkflow.specs.base.TaskSpec, status_code: int = 400) ApiError#

Constructs an API Error with details pulled from the current task.

classmethod from_workflow_exception(error_code: str, message: str, exp: SpiffWorkflow.exceptions.WorkflowException) ApiError#

Deals with workflow exceptions.

We catch a lot of workflow exception errors, so consolidating the error_code, and doing the best things we can with the data we have.

api_error.set_user_sentry_context() None#

Set_user_sentry_context.

api_error.handle_exception(exception: Exception) flask.wrappers.Response#

Handles unexpected exceptions.