How to use the odoorpc.error.Error function in OdooRPC

To help you get started, we’ve selected a few OdooRPC examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OCA / odoorpc / tests / test_login.py View on Github external
def test_login_no_password(self):
        # login no password => Error
        odoo = odoorpc.ODOO(
            ARGS.server, protocol=ARGS.protocol, port=ARGS.port,
            version=ARGS.version)
        self.assertRaises(
            odoorpc.error.Error,
            odoo.login, ARGS.user)
github osiell / odoorpc / tests / test_login.py View on Github external
def test_login_no_password(self):
        # login no password => Error
        odoo = odoorpc.ODOO(
            ARGS.server, protocol=ARGS.protocol, port=ARGS.port,
            version=ARGS.version)
        self.assertRaises(
            odoorpc.error.Error,
            odoo.login, ARGS.user)
github OCA / odoorpc / odoorpc / error.py View on Github external
# -*- coding: utf-8 -*-
# Copyright 2014 Sébastien Alix
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl)
"""This module contains all exceptions raised by `OdooRPC` when an error
occurred.
"""
import sys


class Error(Exception):
    """Base class for exception."""

    pass


class RPCError(Error):
    """Exception raised for errors related to RPC queries.
    Error details (like the `Odoo` server traceback) are available through the
    `info` attribute:

    .. doctest::
        :options: +SKIP

        >>> from pprint import pprint as pp
        >>> try:
        ...     odoo.execute('res.users', 'wrong_method')
        ... except odoorpc.error.RPCError as exc:
        ...     pp(exc.info)
        ...
        {'code': 200,
         'data': {'arguments': ["type object 'res.users' has no attribute 'wrong_method'"],
                  'debug': 'Traceback (most recent call last):\\n  File ...',
github osiell / odoorpc / odoorpc / error.py View on Github external
#
#    You should have received a copy of the GNU Lesser General Public License
#    along with this program.  If not, see .
#
##############################################################################
"""This module contains all exceptions raised by `OdooRPC` when an error
occurred.
"""


class Error(Exception):
    """Base class for exception."""
    pass


class RPCError(Error):
    """Exception raised for errors related to RPC queries.
    Error details (like the `Odoo` server traceback) are available through the
    `info` attribute:

    .. doctest::
        :options: +SKIP

        >>> from pprint import pprint as pp
        >>> try:
        ...     odoo.execute('res.users', 'wrong_method')
        ... except odoorpc.error.RPCError as exc:
        ...     pp(exc.info)
        ...
        {'code': 200,
         'data': {'arguments': ["'res.users' object has no attribute 'wrong_method'"],
                  'debug': 'Traceback (most recent call last):\\n  File ...',
github OCA / odoorpc / odoorpc / error.py View on Github external
def __str__(self):
        # args[0] should always be a unicode object (see '__init__(...)')
        if sys.version_info[0] < 3 and self.args and self.args[0]:
            return self.args[0].encode('utf-8')
        return self.args and self.args[0] or ''

    def __unicode__(self):
        # args[0] should always be a unicode object (see '__init__(...)')
        return self.args and self.args[0] or u''

    def __repr__(self):
        return "{}({})".format(self.__class__.__name__, repr(self.args[0]))


class InternalError(Error):
    """Exception raised for errors occurring during an internal operation."""

    pass
github osiell / odoorpc / odoorpc / error.py View on Github external
def __init__(self, message, info=False):
        super(Error, self).__init__(message, info)
        self.info = info
github OCA / odoorpc / odoorpc / error.py View on Github external
def __init__(self, message, info=False):
        # Ensure that the message is in unicode,
        # to be compatible both with Python2 and 3
        try:
            message = message.decode('utf-8')
        except (UnicodeEncodeError, AttributeError):
            pass
        super(Error, self).__init__(message, info)
        self.info = info
github osiell / odoorpc / odoorpc / error.py View on Github external
True
    """
    def __init__(self, message, info=False):
        super(Error, self).__init__(message, info)
        self.info = info

    def __str__(self):
        return self.args and self.args[0] or ''

    def __repr__(self):
        return "%s(%s)" % (
            self.__class__.__name__,
            repr(self.args[0]))


class InternalError(Error):
    """Exception raised for errors occurring during an internal operation."""
    pass