__init__.py (3783B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\eveexceptions\__init__.py 2 from eveexceptions.const import * 3 from eveexceptions.exceptionEater import ExceptionEater, EatsExceptions 4 import __builtin__ 5 import types 6 if not hasattr(__builtin__, 'strx'): 7 strx = str 8 9 class UserError(Exception): 10 __guid__ = 'exceptions.UserError' 11 __persistvars__ = ['args', 'dict', 'msg'] 12 13 def __init__(self, msg = None, *args): 14 if getattr(msg, '__class__', None) == UserError: 15 self.msg = msg.msg 16 self.dict = msg.dict 17 self.args = (self.msg, self.dict) 18 return 19 if type(msg) not in [types.StringType, types.UnicodeType, types.NoneType]: 20 raise RuntimeError('Invalid argument, msg must be a string', msg) 21 self.msg = msg 22 if len(args) and type(args[0]) == type({}): 23 self.dict = args[0] 24 self.args = (self.msg, self.dict) 25 else: 26 self.dict = None 27 self.args = (self.msg,) + args 28 29 def __str__(self): 30 return 'User error, msg=%s, dict=%s' % (strx(self.msg), strx(self.dict)) 31 32 33 class CancelSessionChange(UserError): 34 pass 35 36 37 class SQLError(RuntimeError): 38 __guid__ = 'exceptions.SQLError' 39 40 def __init__(self, *args): 41 RuntimeError.__init__(self, *args) 42 args = args + (None,) * (6 - len(args)) 43 args = args[:6] 44 code, msg, rawErrorRecords, sql, paramErrors, colErrors = args 45 self.code = code 46 self.msg = msg 47 self.colErrors = colErrors 48 self.sql = sql 49 self.rawErrorRecords = rawErrorRecords 50 self.paramErrors = paramErrors 51 self.errorRecords = [] 52 for r in rawErrorRecords or []: 53 r = r + (None,) * (8 - len(r)) 54 self.errorRecords.append((r[1], 55 None, 56 r[2], 57 r[6], 58 r[7])) 59 60 def __str__(self): 61 return '\nCode: %r\nMessage: %r\nErrorRecs: %r\nSQL: %r\nParamErrors: %r\nColErrors: %r' % (self.code, 62 self.msg, 63 self.rawErrorRecords, 64 self.sql, 65 self.paramErrors, 66 self.colErrors) 67 68 69 class ConnectionError(RuntimeError): 70 __guid__ = 'exceptions.ConnectionError' 71 72 73 class UnmarshalError(Exception): 74 __guid__ = 'exceptions.UnmarshalError' 75 76 def __init__(self, exception = None, value = None, size = 0, pos = 0, crc = 0): 77 self.exception = exception 78 self.value = value 79 self.size = size 80 self.pos = pos 81 self.crc = crc 82 83 def __str__(self): 84 return '\nException: %s, %s\nPikl size: %s\nPikl pos.: %s\nCRC: %s' % (strx(self.exception), 85 strx(self.value), 86 strx(self.size), 87 strx(self.pos), 88 strx(self.crc)) 89 90 91 class RoleNotAssignedError(Exception): 92 __guid__ = 'exceptions.RoleNotAssignedError' 93 94 def __init__(self, roles = None): 95 self.roles = roles 96 97 def __str__(self): 98 return '\nRequired roles: %s' % (strx(self.roles),) 99 100 101 class ServiceNotFound(Exception): 102 __guid__ = 'exceptions.ServiceNotFound' 103 __persistvars__ = ['serviceName'] 104 105 def __init__(self, serviceName = None): 106 self.serviceName = serviceName 107 Exception.__init__(self, serviceName) 108 109 def __repr__(self): 110 return 'The service ' + unicode(self.serviceName) + ' was not found.' 111 112 113 class MethodNotCalledFromClient(Exception): 114 __guid__ = 'exception.MethodNotCalledFromClient' 115 __persistvars__ = ['methodName'] 116 117 def __init__(self, methodName = None): 118 self.methodName = methodName 119 Exception.__init__(self, methodName) 120 121 def __repr__(self): 122 return 'The method ' + unicode(self.methodName) + ' can be called from the client only.'