'''
Exceptions used by synapse, all inheriting from SynErr
'''
[docs]
class SynErr(Exception):
def __init__(self, *args, **info):
self.errinfo = info
self.errname = self.__class__.__name__
Exception.__init__(self, self._getExcMsg())
def _getExcMsg(self):
props = sorted(self.errinfo.items())
displ = ' '.join(['%s=%r' % (p, v) for (p, v) in props])
return '%s: %s' % (self.__class__.__name__, displ)
def _setExcMesg(self):
'''Should be called when self.errinfo is modified.'''
self.args = (self._getExcMsg(),)
def __setstate__(self, state):
'''Pickle support.'''
super(SynErr, self).__setstate__(state)
self._setExcMesg()
[docs]
def items(self):
return {k: v for k, v in self.errinfo.items()}
[docs]
def get(self, name, defv=None):
'''
Return a value from the errinfo dict.
Example:
try:
foothing()
except SynErr as e:
blah = e.get('blah')
'''
return self.errinfo.get(name, defv)
[docs]
def set(self, name, valu):
'''
Set a value in the errinfo dict.
'''
self.errinfo[name] = valu
self._setExcMesg()
[docs]
def setdefault(self, name, valu):
'''
Set a value in errinfo dict if it is not already set.
'''
if name in self.errinfo:
return
self.errinfo[name] = valu
self._setExcMesg()
[docs]
def update(self, items: dict):
'''Update multiple items in the errinfo dict at once.'''
self.errinfo.update(**items)
self._setExcMesg()
[docs]
class StormRaise(SynErr):
'''
This represents a user provided exception raised in the Storm runtime. It requires a errname key.
'''
def __init__(self, *args, **info):
SynErr.__init__(self, *args, **info)
name = info.get('errname')
if name is not None:
self.errname = name
else:
raise BadArg(mesg='StormRaise must have a key errname provided')
[docs]
class AuthDeny(SynErr): pass
[docs]
class BackupAlreadyRunning(SynErr):
'''
Only one backup may be running at a time
'''
[docs]
class StormPkgRequires(SynErr): pass
[docs]
class StormPkgConflicts(SynErr): pass
[docs]
class BadName(SynErr): pass
[docs]
class BadPkgDef(SynErr): pass
[docs]
class BadCmdName(SynErr): pass
[docs]
class BadCmprValu(SynErr): pass
[docs]
class BadCmprType(SynErr):
'''
Attempt to compare two incomparable values
'''
[docs]
class BadCast(SynErr): pass
[docs]
class BadConfValu(SynErr):
'''
The configuration value provided is not valid.
This should contain the config name, valu and mesg.
'''
pass
[docs]
class NeedConfValu(SynErr): pass
[docs]
class BadCoreStore(SynErr):
'''The storage layer has encountered an error'''
pass
[docs]
class BadCtorType(SynErr): pass
[docs]
class BadHivePath(SynErr): pass
[docs]
class BadLiftValu(SynErr): pass
[docs]
class BadPropDef(SynErr): pass
[docs]
class BadEdgeDef(SynErr): pass
[docs]
class BadTypeDef(SynErr): pass
[docs]
class BadTypeValu(SynErr): pass
[docs]
class BadJsonText(SynErr): pass
[docs]
class BadDataValu(SynErr):
'''Cannot process the data as intended.'''
pass
[docs]
class BadArg(SynErr):
''' Improper function arguments '''
pass
[docs]
class BadState(SynErr): pass
[docs]
class BadFileExt(SynErr): pass
[docs]
class BadIndxValu(SynErr): pass
[docs]
class BadMesgVers(SynErr): pass
[docs]
class BadOperArg(SynErr):
''' Improper storm function arguments '''
pass
[docs]
class BadOptValu(SynErr): pass
[docs]
class BadVersion(SynErr):
'''Generic Bad Version exception.'''
pass
[docs]
class BadStorageVersion(SynErr):
''' Stored persistent data is incompatible with running software '''
pass
[docs]
class BadSyntax(SynErr): pass
[docs]
class BadTag(SynErr): pass
[docs]
class BadTime(SynErr): pass
[docs]
class BadUrl(SynErr): pass
[docs]
class TypeMismatch(SynErr): pass
[docs]
class CantDelCmd(SynErr): pass
[docs]
class CantDelNode(SynErr): pass
[docs]
class CantDelProp(SynErr): pass
[docs]
class CantDelType(SynErr): pass
[docs]
class CantDelUniv(SynErr): pass
[docs]
class CantDelView(SynErr): pass
[docs]
class CantMergeView(SynErr): pass
[docs]
class CantRevLayer(SynErr): pass
[docs]
class CliFini(SynErr):
'''
Raised when the CLI is to exit.
'''
pass
[docs]
class CryptoErr(SynErr):
'''
Raised when there is a synapse.lib.crypto error.
'''
pass
[docs]
class BadEccExchange(CryptoErr):
''' Raised when there is an issue doing a ECC Key Exchange '''
pass
[docs]
class BadCertBytes(SynErr):
'''Raised by certdir when the certificate fails to load.'''
[docs]
class BadCertVerify(SynErr):
'''Raised by certdir when there is a failure to verify a certificate context.'''
[docs]
class PathExists(SynErr): pass
[docs]
class DataAlreadyExists(SynErr):
'''
Cannot copy data to a location that already contains data
'''
pass
[docs]
class DbOutOfSpace(SynErr): pass
[docs]
class DupName(SynErr): pass
[docs]
class DupIden(SynErr): pass
[docs]
class DupIndx(SynErr): pass
[docs]
class DupFileName(SynErr): pass
[docs]
class DupPropName(SynErr): pass
[docs]
class DupRoleName(SynErr): pass
[docs]
class DupTagPropName(SynErr): pass
[docs]
class DupUserName(SynErr): pass
[docs]
class DupStormSvc(SynErr): pass
[docs]
class DupTypeName(SynErr):
[docs]
@classmethod
def init(cls, name, mesg=None):
if mesg is None:
mesg = f'Type already exists: {name}.'
return DupTypeName(mesg=mesg, name=name)
[docs]
class DupEdgeType(SynErr):
[docs]
@classmethod
def init(cls, edge, mesg=None):
if mesg is None:
(n1form, verb, n2form) = edge
mesg = f'Edge already exists: {n1form} -({verb})> {n2form}.'
return DupEdgeType(mesg=mesg, n1form=n1form, verb=verb, n2form=n2form)
[docs]
class FileExists(SynErr): pass
[docs]
class InconsistentStorage(SynErr):
'''
Stored persistent data is inconsistent
'''
pass
[docs]
class IsFini(SynErr): pass
[docs]
class IsReadOnly(SynErr): pass
[docs]
class IsDeprLocked(SynErr): pass
[docs]
class LayerInUse(SynErr): pass
[docs]
class LinkErr(SynErr): pass
[docs]
class LinkBadCert(LinkErr): pass
[docs]
class LinkShutDown(LinkErr): pass
[docs]
class LowSpace(SynErr): pass
[docs]
class NoCertKey(SynErr):
''' Raised when a Cert object requires a RSA Private Key to perform an operation and the key is not present. '''
pass
[docs]
class NoSuchCert(SynErr): pass
[docs]
class BadCertHost(SynErr): pass
[docs]
class ModAlreadyLoaded(SynErr): pass
[docs]
class MustBeJsonSafe(SynErr): pass
[docs]
class NotMsgpackSafe(SynErr): pass
[docs]
class NoSuchType(SynErr):
[docs]
@classmethod
def init(cls, name, mesg=None):
if mesg is None:
mesg = f'No type named {name}.'
return NoSuchType(mesg=mesg, name=name)
[docs]
class NoSuchProp(SynErr):
[docs]
@classmethod
def init(cls, name, mesg=None):
if mesg is None:
mesg = f'No property named {name}.'
return NoSuchProp(mesg=mesg, name=name)
[docs]
class NoSuchEdge(SynErr):
[docs]
@classmethod
def init(cls, edge, mesg=None):
if mesg is None:
(n1form, verb, n2form) = edge
mesg = f'No edge defined for {n1form} -({verb})> {n2form}.'
return NoSuchEdge(mesg=mesg, n1form=n1form, verb=verb, n2form=n2form)
[docs]
class NoSuchAbrv(SynErr): pass
[docs]
class NoSuchAct(SynErr): pass
[docs]
class NoSuchAuthGate(SynErr): pass
[docs]
class NoSuchCmd(SynErr): pass
[docs]
class NoSuchPkg(SynErr): pass
[docs]
class NoSuchCmpr(SynErr): pass
[docs]
class NoSuchCond(SynErr): pass
[docs]
class NoSuchCtor(SynErr): pass
[docs]
class NoSuchDecoder(SynErr): pass
[docs]
class NoSuchDir(SynErr): pass
[docs]
class NoSuchDyn(SynErr): pass
[docs]
class NoSuchEncoder(SynErr): pass
[docs]
class NoSuchFile(SynErr): pass
[docs]
class NoSuchFunc(SynErr): pass
[docs]
class NoSuchIden(SynErr): pass
[docs]
class NoSuchImpl(SynErr): pass
[docs]
class NoSuchIndx(SynErr): pass
[docs]
class NoSuchLayer(SynErr): pass
[docs]
class NoSuchLift(SynErr): pass
[docs]
class NoSuchMeth(SynErr): pass
[docs]
class NoSuchName(SynErr): pass
[docs]
class NoSuchObj(SynErr): pass
[docs]
class NoSuchOpt(SynErr): pass
[docs]
class NoSuchPath(SynErr): pass
[docs]
class NoSuchPivot(SynErr): pass
[docs]
class NoSuchUniv(SynErr): pass
[docs]
class NoSuchRole(SynErr): pass
[docs]
class NoSuchUser(SynErr): pass
[docs]
class NoSuchVar(SynErr): pass
[docs]
class NoSuchView(SynErr): pass
[docs]
class NoSuchTagProp(SynErr): pass
[docs]
class NoSuchStormSvc(SynErr): pass
[docs]
class NotANumberCompared(SynErr): pass
[docs]
class ParserExit(SynErr):
''' Raised by synapse.lib.cmd.Parser on Parser exit() '''
pass
[docs]
class DmonSpawn(SynErr):
'''
Raised by a dispatched telepath method that has answered the call
using a spawned process. ( control flow that is compatible with
aborting standard calls, generators, and async generators ).
'''
pass
[docs]
class SchemaViolation(SynErr): pass
[docs]
class SlabAlreadyOpen(SynErr): pass
[docs]
class SlabInUse(SynErr): pass
[docs]
class SpawnExit(SynErr): pass
[docs]
class FeatureNotSupported(SynErr): pass
[docs]
class HitLimit(SynErr): pass
[docs]
class ReadOnlyLayer(SynErr): pass
[docs]
class ReadOnlyProp(SynErr): pass
[docs]
class RecursionLimitHit(SynErr): pass
[docs]
class TimeOut(SynErr): pass
[docs]
class Retry(SynErr): pass
[docs]
class NotReady(Retry): pass
[docs]
class StepTimeout(SynErr):
'''
Raised when a TestStep.wait() call times out.
'''
pass
[docs]
class StormRuntimeError(SynErr): pass
[docs]
class StormVarListError(StormRuntimeError): pass
[docs]
class FatalErr(SynErr):
'''
Raised when a fatal error has occurred which an application cannot recover from.
'''
pass
[docs]
class LmdbLock(SynErr): pass