mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-14 02:25:02 +08:00
This patch drops message objects, defined by class BaseMessage and its subclasses, and pass event info arguments to event handler directly. Different event handler requires different arguments to handle a kind of specific event. The event info is parsed from the raw message received from message bus. Signed-off-by: Chenxiong Qi <cqi@redhat.com>
51 lines
820 B
Python
51 lines
820 B
Python
# -*- coding: utf-8 -*-
|
|
# SPDX-License-Identifier: MIT
|
|
""" Defines custom exceptions and error handling functions """
|
|
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"""
|