Skip to content

Commit

Permalink
rest_log: move exceptions to their own file
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk committed Feb 4, 2021
1 parent a8b7de6 commit 3ee17ba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
23 changes: 5 additions & 18 deletions rest_log/components/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,11 @@

from odoo.addons.component.core import AbstractComponent


class RESTServiceDispatchException(Exception):

rest_json_info = {}

def __init__(self, message, log_entry_url):
super().__init__(message)
self.rest_json_info = {"log_entry_url": log_entry_url}


class RESTServiceUserErrorException(RESTServiceDispatchException, exceptions.UserError):
"""User error wrapped exception."""


class RESTServiceValidationErrorException(
RESTServiceDispatchException, exceptions.ValidationError
):
"""Validation error wrapped exception."""
from ..exceptions import (
RESTServiceDispatchException,
RESTServiceUserErrorException,
RESTServiceValidationErrorException,
)


class BaseRESTService(AbstractComponent):
Expand Down
25 changes: 25 additions & 0 deletions rest_log/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 Camptocamp SA (http://www.camptocamp.com)
# @author Simone Orsi <[email protected]>

from odoo import exceptions as odoo_exceptions


class RESTServiceDispatchException(Exception):

rest_json_info = {}

def __init__(self, message, log_entry_url):
super().__init__(message)
self.rest_json_info = {"log_entry_url": log_entry_url}


class RESTServiceUserErrorException(
RESTServiceDispatchException, odoo_exceptions.UserError
):
"""User error wrapped exception."""


class RESTServiceValidationErrorException(
RESTServiceDispatchException, odoo_exceptions.ValidationError
):
"""Validation error wrapped exception."""

0 comments on commit 3ee17ba

Please sign in to comment.