forked from OCA/edi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] EDIWebserviceSendHTTPException to catch http error form edi_web…
…service_oca
- Loading branch information
Matthias BARKAT
committed
Jun 10, 2024
1 parent
5c39f74
commit 6269113
Showing
3 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,15 @@ | |
# @author: Simone Orsi <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from requests.exceptions import HTTPError | ||
|
||
from odoo import _, exceptions | ||
|
||
from odoo.addons.component.core import Component | ||
|
||
from ..exceptions import EDIWebserviceSendHTTPException | ||
|
||
|
||
class EDIWebserviceSend(Component): | ||
"""Generic component for webservice requests. | ||
|
@@ -27,7 +32,10 @@ def __init__(self, work_context): | |
|
||
def send(self): | ||
method, pargs, kwargs = self._get_call_params() | ||
return self.webservice_backend.call(method, *pargs, **kwargs) | ||
try: | ||
return self.webservice_backend.call(method, *pargs, **kwargs) | ||
except HTTPError as err: | ||
raise EDIWebserviceSendHTTPException("EDI HTTP Error: %s" % err) from err | ||
|
||
def _get_call_params(self): | ||
try: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from requests.exceptions import HTTPError | ||
|
||
|
||
class EDIWebserviceSendHTTPException(HTTPError): | ||
"""Exception raised when an HTTP error occurs during a webservice call.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters