aiocoap.error module

Exception definitions for txThings CoAP library.

exception aiocoap.error.Error

Bases: Exception

Base exception for all exceptions that indicate a failed request

exception aiocoap.error.RenderableError

Bases: aiocoap.error.Error

Exception that can meaningfully be represented in a CoAP response


Create a CoAP message that should be sent when this exception is rendered

exception aiocoap.error.ResponseWrappingError(coapmessage)

Bases: aiocoap.error.Error

An exception that is raised due to an unsuccessful but received response.

A better relationship with should be worked out to do except UnsupportedMediaType (similar to the various OSError subclasses).

exception aiocoap.error.ConstructionRenderableError(message=None)

Bases: aiocoap.error.RenderableError

RenderableError that is constructed from class attributes code and message (where the can be overridden in the constructor).

code = <Response Code 160 "5.00 Internal Server Error">

Code assigned to messages built from it

message = ''

Text sent in the built message’s payload

exception aiocoap.error.NotFound(message=None)

Bases: aiocoap.error.ConstructionRenderableError

code = <Response Code 132 "4.04 Not Found">
exception aiocoap.error.MethodNotAllowed(message=None)

Bases: aiocoap.error.ConstructionRenderableError

code = <Response Code 133 "4.05 Method Not Allowed">
exception aiocoap.error.UnsupportedContentFormat(message=None)

Bases: aiocoap.error.ConstructionRenderableError

code = <Response Code 143 "4.15 Unsupported Media Type">

alias of UnsupportedContentFormat

exception aiocoap.error.BadRequest(message=None)

Bases: aiocoap.error.ConstructionRenderableError

code = <Response Code 128 "4.00 Bad Request">
exception aiocoap.error.NoResource

Bases: aiocoap.error.NotFound

Raised when resource is not found.

message = 'Error: Resource not found!'
exception aiocoap.error.UnallowedMethod(message=None)

Bases: aiocoap.error.MethodNotAllowed

Raised by a resource when request method is understood by the server but not allowed for that particular resource.

message = 'Error: Method not allowed!'
exception aiocoap.error.UnsupportedMethod(message=None)

Bases: aiocoap.error.MethodNotAllowed

Raised when request method is not understood by the server at all.

message = 'Error: Method not recognized!'
exception aiocoap.error.NotImplemented

Bases: aiocoap.error.Error

Raised when request is correct, but feature is not implemented by txThings library. For example non-sequential blockwise transfers

exception aiocoap.error.RequestTimedOut

Bases: aiocoap.error.Error

Raised when request is timed out.

exception aiocoap.error.WaitingForClientTimedOut

Bases: aiocoap.error.Error

Raised when server expects some client action:

  • sending next PUT/POST request with block1 or block2 option
  • sending next GET request with block2 option

but client does nothing.

exception aiocoap.error.ResourceChanged

Bases: aiocoap.error.Error

The requested resource was modified during the request and could therefore not be received in a consistent state.

exception aiocoap.error.UnexpectedBlock1Option

Bases: aiocoap.error.Error

Raised when a server responds with block1 options that just don’t match.

exception aiocoap.error.UnexpectedBlock2

Bases: aiocoap.error.Error

Raised when a server responds with another block2 than expected.

exception aiocoap.error.MissingBlock2Option

Bases: aiocoap.error.Error

Raised when response with Block2 option is expected (previous response had Block2 option with More flag set), but response without Block2 option is received.

exception aiocoap.error.NotObservable

Bases: aiocoap.error.Error

The server did not accept the request to observe the resource.

exception aiocoap.error.ObservationCancelled

Bases: aiocoap.error.Error

The server claimed that it will no longer sustain the observation.

exception aiocoap.error.UnparsableMessage

Bases: aiocoap.error.Error

An incoming message does not look like CoAP.

Note that this happens rarely – the requirements are just two bit at the beginning of the message, and a minimum length.

exception aiocoap.error.CommunicationKilled(message=None)

Bases: aiocoap.error.ConstructionRenderableError

The communication process has been aborted by request of the application.

code = <Response Code 163 "5.03 Service Unavailable">