2014-12-02 12:54:01 +01:00
|
|
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
|
|
|
|
# this repository contains the full copyright notices and license terms.
|
2011-09-06 11:20:34 +02:00
|
|
|
|
2012-04-01 23:08:15 +02:00
|
|
|
|
2016-03-15 16:57:26 +01:00
|
|
|
class TrytonException(Exception):
|
2018-06-26 19:11:19 +02:00
|
|
|
pass
|
2016-03-15 16:57:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserError(TrytonException):
|
2011-09-06 11:20:34 +02:00
|
|
|
|
2019-06-16 19:04:55 +02:00
|
|
|
def __init__(self, message, description='', domain=None):
|
|
|
|
|
super().__init__('UserError', (message, description, domain))
|
2011-09-06 11:20:34 +02:00
|
|
|
self.message = message
|
|
|
|
|
self.description = description
|
2019-06-16 19:04:55 +02:00
|
|
|
self.domain = domain
|
2011-09-06 11:20:34 +02:00
|
|
|
self.code = 1
|
|
|
|
|
|
2019-10-30 14:09:20 +01:00
|
|
|
def __str__(self):
|
2018-06-26 19:11:19 +02:00
|
|
|
return '%s - %s' % (self.message, self.description)
|
2017-03-13 22:56:11 +01:00
|
|
|
|
2011-09-06 11:20:34 +02:00
|
|
|
|
2016-03-15 16:57:26 +01:00
|
|
|
class UserWarning(TrytonException):
|
2018-12-29 14:19:08 +01:00
|
|
|
"Exception that will be displayed as a warning message in the client."
|
2011-09-06 11:20:34 +02:00
|
|
|
|
|
|
|
|
def __init__(self, name, message, description=''):
|
|
|
|
|
super(UserWarning, self).__init__('UserWarning', (name, message,
|
|
|
|
|
description))
|
|
|
|
|
self.name = name
|
|
|
|
|
self.message = message
|
|
|
|
|
self.description = description
|
|
|
|
|
self.code = 2
|
|
|
|
|
|
2019-10-30 14:09:20 +01:00
|
|
|
def __str__(self):
|
2018-06-26 19:11:19 +02:00
|
|
|
return '%s - %s' % (self.message, self.description)
|
2017-03-13 22:56:11 +01:00
|
|
|
|
2011-09-06 11:20:34 +02:00
|
|
|
|
2016-05-31 12:49:23 +02:00
|
|
|
class LoginException(TrytonException):
|
|
|
|
|
"""Request the named parameter for the login process.
|
|
|
|
|
The type can be 'password' or 'char'.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __init__(self, name, message, type='password'):
|
|
|
|
|
super(LoginException, self).__init__(
|
|
|
|
|
'LoginException', (name, message, type))
|
|
|
|
|
self.name = name
|
|
|
|
|
self.message = message
|
|
|
|
|
self.type = type
|
|
|
|
|
self.code = 3
|
|
|
|
|
|
|
|
|
|
|
2016-03-15 16:57:26 +01:00
|
|
|
class ConcurrencyException(TrytonException):
|
2011-09-06 11:20:34 +02:00
|
|
|
|
|
|
|
|
def __init__(self, message):
|
|
|
|
|
super(ConcurrencyException, self).__init__('ConcurrencyException',
|
|
|
|
|
message)
|
|
|
|
|
self.message = message
|
|
|
|
|
self.code = 4
|
2017-02-02 11:55:44 +01:00
|
|
|
|
2019-10-30 14:09:20 +01:00
|
|
|
def __str__(self):
|
2017-03-13 22:56:11 +01:00
|
|
|
return self.message
|
|
|
|
|
|
2017-02-02 11:55:44 +01:00
|
|
|
|
|
|
|
|
class RateLimitException(TrytonException):
|
|
|
|
|
"""User has sent too many requests in a given amount of time."""
|
2017-06-30 09:50:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class MissingDependenciesException(TrytonException):
|
|
|
|
|
|
|
|
|
|
def __init__(self, missings):
|
|
|
|
|
self.missings = missings
|
|
|
|
|
|
2019-10-30 14:09:20 +01:00
|
|
|
def __str__(self):
|
2017-06-30 09:50:49 +02:00
|
|
|
return 'Missing dependencies: %s' % ' '.join(self.missings)
|