Files
fm-orchestrator/module_build_service/common/errors.py
mprahl 81f2bffdda Rearrange the imports to meet the style guide
This also includes `from __future__ import absolute_import`
in every file so that the imports are consistent in Python 2 and 3.
The Python 2 tests fail without this.
2020-03-03 14:48:47 -05:00

54 lines
861 B
Python

# -*- coding: utf-8 -*-
# SPDX-License-Identifier: MIT
""" Defines custom exceptions and error handling functions """
from __future__ import absolute_import
from flask import jsonify
class ValidationError(ValueError):
pass
class Unauthorized(ValueError):
pass
class Forbidden(ValueError):
pass
class UnprocessableEntity(ValueError):
pass
class Conflict(ValueError):
pass
class NotFound(ValueError):
pass
class ProgrammingError(ValueError):
pass
class StreamAmbigous(ValueError):
pass
class GreenwaveError(RuntimeError):
pass
def json_error(status, error, message):
response = jsonify({"status": status, "error": error, "message": message})
response.status_code = status
return response
class IgnoreMessage(Exception):
"""Raise if message received from message bus should be ignored"""