"""Application and custom Exceptions.""" from flask import Response from owsresponse import response from owsresponse.adaptors.flask import flaskify from werkzeug.exceptions import BadRequest, Conflict, NotFound from vectororder.constants import error as error_const class RequestError(Exception): """Request Error Exception class.""" def __init__( self, message: str, error_code: str = error_const.ERROR_CODE_BAD_REQUEST ) -> None: """Construct. Args: message (str/dict): Response message. error_code (str): Error code key. """ super().__init__() self.message = message self.error_code = error_code def __str__(self) -> str: """Convert message to string.""" return str(self.message) def make_flask_response(self) -> Response: """Make Flask Response.""" return flaskify(response.create_error_response(self.error_code, self.message)) class JobNotFoundError(NotFound): """Job Not Found Error Exception class.""" pass class VendorNotFoundError(NotFound): """Vendor Not Found Error Exception class.""" pass class OrderNotFoundError(NotFound): """Order not found exception.""" pass class ProductNotFoundError(NotFound): """Product not found exception.""" pass class ProductNotInContent(Conflict): """Product release status is not in content.""" pass class InvalidOrderRequest(BadRequest): """Invalid Order Request Exception class.""" pass class DeliveryFileNotFoundError(NotFound): """Delivery file not found Exception class.""" pass class DeliveryFileNotAvailableError(NotFound): """Delivery file not available Exception class.""" pass