gavo.utils.excs module

Global exceptions for the GAVO data center software.

All exceptions escaping modules should inherit from Error in some way. Exceptions originating in only one module should usually be defined there, exceptions should only be defined here if they are raised by more than one module.

Of course, for certain errors, built-in exceptions (e.g., NotImplemented or so) may be raised and propagated as well, but these should always signify internal bugs, never things a user should be confronted with under normal circumstances.

And then there’s stuff like fancyconfig that’s supposed to live independently of the rest. It’s ok if those raise other Exceptions, but clearly there shouldn’t be many of those, or error reporting will become an even worse nightmare than it already is.

exception gavo.utils.excs.BadCode(code: str, codeType: str, origExc: Exception, hint: Optional[str] = None, pos: Optional[ParsePosition] = None)[source]

Bases: StructureError

is raised when some code could not be compiled.

BadCodes are constructed with the offending code, a code type, the original exception, and optionally a hint and a position.

exception gavo.utils.excs.DataError(msg: str = '', hint: Optional[str] = None)[source]

Bases: Error

is raised when something is wrong with a data set.

When facing the web, these yield HTTP status 406.

exception gavo.utils.excs.EmptyData(msg: str = '', hint: Optional[str] = None)[source]

Bases: Error

is raised within certain protocols to signify a request was successful but yielded no data.

exception gavo.utils.excs.Error(msg: str = '', hint: Optional[str] = None)[source]

Bases: Exception

The base class for all exceptions that can be expected to escape a module.

Apart from the normal message, you can give a hint constructor argument.

exception gavo.utils.excs.ExecutiveAction[source]

Bases: Exception

is a base class for exceptions that are supposed to break out of deep things and trigger actions higher up.

exception gavo.utils.excs.LiteralParseError(attName: str, literal: str, pos: Optional[ParsePosition] = None, hint: Optional[str] = None)[source]

Bases: StructureError

is raised if an attribute literal is somehow bad.

LiteralParseErrors are constructed with the name of the attribute that was being parsed, the offending literal, and optionally a parse position and a hint.

exception gavo.utils.excs.MultiplicityError(msg: str, colName: str, row: Optional[dict] = None, hint: Optional[str] = None)[source]

Bases: ValidationError

is raised when a singleton is passed in multiple times or vice versa.

exception gavo.utils.excs.NotFoundError(lookedFor: str, what: str, within: str, hint: Optional[str] = None)[source]

Bases: Error

is raised when something is asked for something that does not exist.

lookedFor can be an arbitrary object, so be careful when your repr it – that may be long.

exception gavo.utils.excs.RDNotFound(rdId: str, hint: Optional[str] = None)[source]

Bases: NotFoundError

is raised when an RD cannot be located.

cacheable = True
exception gavo.utils.excs.ReportableError(msg: str = '', hint: Optional[str] = None)[source]

Bases: Error

is raised when something decides it can come up with an error message that should be presented to the user as-is.

UIs should, consequently, just dump the payload and not try adornments. The content should be treated as a unicode string.

exception gavo.utils.excs.RestrictedElement(elName: str, pos: Optional[ParsePosition] = None, hint: Optional[str] = None)[source]

Bases: StructureError

is raised when elements forbidden in restricted RDs are encountered when restricted parsing is in effect.

exception gavo.utils.excs.SkipThis[source]

Bases: ExecutiveAction

is caught in rsc.makeData. You can raise this at any place during source processing to skip the rest of this source but the go on.

You should pass something descriptive as message so upstream can potentially report something is skipped and why.

Note: in a rowmaker, you probably usually want to raise IgnoreThisRow instead; it’s rare that you want to ignore the rest of a source just because you don’t like a row.

exception gavo.utils.excs.SourceParseError(msg: str, offending: Optional[str] = None, location: str = 'unspecified location', source: str = '<unspecified source>', hint: Optional[str] = None)[source]

Bases: Error

is raised when some syntax error occurs during a source parse.

They are constructed with the offending input construct (a source line or similar, None in a pinch) and the result of the row iterator’s getLocator call.

exception gavo.utils.excs.StructureError(msg: str, pos: Optional[ParsePosition] = None, hint: Optional[str] = None)[source]

Bases: Error

is raised if an error occurs during the construction of structures.

You can construct these with pos; this is an opaque object that, when stringified, should expand to something that gives the user a rough idea of where something went wrong.

Since you will usually not know where you are in the source document when you want to raise a StructureError, xmlstruct will try to fill pos in when it’s still None when it sees a StructureError. Thus, you’re probably well advised to leave it blank.

addPos(baseMsg: str)[source]
exception gavo.utils.excs.ValidationError(msg: str, colName: str, row: Optional[dict] = None, hint: Optional[str] = None)[source]

Bases: Error

is raised when the validation of a field fails.

ValidationErrors are constructed with a message, a column name, and optionally a row (i.e., a dict) and a hint.