labthings_fastapi.exceptions
A submodule for custom LabThings-FastAPI Exceptions.
Exceptions
The Thing is not connected to a server. |
|
The ThingServer is not running. |
|
A property is read-only. |
|
The property is not observable. |
|
Different type hints have been given for a descriptor. |
|
No type hints have been given for a descriptor that requires a type. |
|
|
|
A |
|
An invocation was cancelled by the user. |
|
The invocation ended in an anticipated error state. |
|
An invocation-specific resource has been requested from outside an invocation. |
|
There is a problem with logging configuration. |
|
Raised if an API route accesses Invocation outputs without a BlobIOContextDep. |
|
Raised if URLFor is serialised without a url_for context variable being set. |
|
A constraint argument is not supported. |
|
The action could not be started. |
|
The action ended with an error on the server. |
|
Setting or getting a property via a ThingClient failed. |
|
A |
Module Contents
- exception labthings_fastapi.exceptions.NotConnectedToServerError
Bases:
RuntimeErrorThe Thing is not connected to a server.
This exception is called if an Action is called or a
DataPropertyis updated on a Thing that is not connected to a ThingServer.A server connection is needed to manage asynchronous behaviour.
Thinginstances are also only assigned apathwhen they are added to a server, so this error may be raised by functions that implement the HTTP API if an attempt is made to construct the API before theThinghas been assigned a path.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.ServerNotRunningError
Bases:
RuntimeErrorThe ThingServer is not running.
This exception is called when a function assumes the ThingServer is running, and it is not. This might be because the function needs to call code in the async event loop.
Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.ReadOnlyPropertyError
Bases:
AttributeErrorA property is read-only.
No setter has been defined for this
FunctionalProperty, so it may not be written to.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.PropertyNotObservableError
Bases:
RuntimeErrorThe property is not observable.
This exception is raised when
Thing.observe_propertyis called with a property that is not observable. Currently, only data properties are observable: functional properties (using a getter/setter) may not be observed.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.InconsistentTypeError
Bases:
TypeErrorDifferent type hints have been given for a descriptor.
Some descriptors in LabThings, particularly
DataPropertyandThingSlotmay have their type specified in different ways. If multiple type hints are provided, they must match. Seepropertyfor more details.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.MissingTypeError
Bases:
TypeErrorNo type hints have been given for a descriptor that requires a type.
Every property and thing connection should have a type hint, There are different ways of providing these type hints. This error indicates that no type hint was found.
See documentation for
propertyandthing_slotfor more details.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.ThingNotConnectedError
Bases:
RuntimeErrorThingSlots have not yet been set up.This error is raised if a
ThingSlotis accessed before theThinghas been supplied by the LabThings server. This usually happens because either theThingis being used without a server (in which case the attribute should be mocked), or because it has been accessed before__enter__has been called.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.ThingSlotError
Bases:
RuntimeErrorA
ThingSlotcould not be set up.This error is raised if the LabThings server is unable to set up a
ThingSlot, for example because the named Thing does not exist, or is of the wrong type, or is not specified and there is no default.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.InvocationCancelledError
Bases:
BaseExceptionAn invocation was cancelled by the user.
Note that this inherits from BaseException so won’t be caught by
except Exception, it must be handled specifically.Action code may want to handle cancellation gracefully. This exception should be propagated if the action’s status should be reported as
cancelled, or it may be handled so that the action finishes, returns a value, and is marked ascompleted.If this exception is handled and not re-raised, or if it arises in a manually-created thread, the action will continue as normal. It is a good idea to make sure your action terminates soon after this exception is raised.
Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.InvocationError
Bases:
RuntimeErrorThe invocation ended in an anticipated error state.
When this error is raised, action execution stops as expected. The exception will be logged at error level without a traceback, and the invocation will return with error status.
Subclass this error for errors that do not need further traceback information to be provided with the error message in logs.
Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.NoInvocationContextError
Bases:
RuntimeErrorAn invocation-specific resource has been requested from outside an invocation.
This error is raised when the current invocation ID is requested, and there is no current invocation ID. Invocation ID is determined from context (using a
ContextVar) and is available from within action functions.To avoid this error in test code or manually created threads, you should supply an invocation context.
Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.LogConfigurationError
Bases:
RuntimeErrorThere is a problem with logging configuration.
LabThings uses the
loggingmodule to collect logs from actions. This requires certain handlers and filters to be set up. This exception is raised if they cannot be added, or if they are not present when they are needed.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.NoBlobManagerError
Bases:
RuntimeErrorRaised if an API route accesses Invocation outputs without a BlobIOContextDep.
Any access to an invocation output must have BlobIOContextDep as a dependency, as the output may be a blob, and the blob needs this context to resolve its URL.
Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.NoUrlForContextError
Bases:
RuntimeErrorRaised if URLFor is serialised without a url_for context variable being set.
This usually indicates that URLFor is being serialised somewhere other than in an HTTP response, for example in test code or in a background task. In these cases, you should set up the url_for context variable manually, for example using the
testing.use_dummy_url_forcontext manager.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.UnsupportedConstraintError
Bases:
ValueErrorA constraint argument is not supported.
This exception is raised when a constraint argument is passed to a property that is not in the supported list. See
labthings_fastapi.properties.CONSTRAINT_ARGSfor the list of supported arguments. Their meaning is described in thepydantic.Fielddocumentation.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.FailedToInvokeActionError
Bases:
RuntimeErrorThe action could not be started.
This error is raised by a
ThingClientinstance if an action could not be started. It most commonly occurs because the input to the action could not be converted to the required type: the error message should give more detail on what’s wrong.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.ServerActionError
Bases:
RuntimeErrorThe action ended with an error on the server.
This error is raised by a
ThingClientwhen an action is successfully invoked on the server, but does not complete. The error message should include more information on why this happened.Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.ClientPropertyError
Bases:
RuntimeErrorSetting or getting a property via a ThingClient failed.
Initialize self. See help(type(self)) for accurate signature.
- exception labthings_fastapi.exceptions.NotBoundToInstanceError
Bases:
RuntimeErrorA
BaseDescriptorInfois not bound to an object.Some methods and properties of
BaseDescriptorInfoobjects require them to be bound to aThinginstance. If these methods are called on aBaseDescriptorInfoobject that is unbound, this exception is raised.This exception should only be seen when
BaseDescriptorInfoobjects are generated from aThingclass. Usually, they should be accessed via aThinginstance, in which case they will be bound.Initialize self. See help(type(self)) for accurate signature.