Skip to main content

Module error

Module error 

Source
Expand description

Easy error handling types for the Matrix API

Contains the trait MatrixApiError, and a couple of error types that are shared across a lot of endpoints. Every error that can be returned to the user should implement MatrixApiError, and [axum::response::IntoResponse], preferably through the derive macro MatrixApiError

The point of MatrixApiError, in contrast to other error types in Arminius, is to handle errors from which no recovery is possible. This can happen either because it’s a “this should never happen bug”, like an invalid database state, or because the error is due to user input.

From this it follows that the only job of a MatrixApiError is to return information to the user, and not to provide diagnostics. Diagnostics should, if needed, be emitted in the From<T> trait for the relevant error type, because that is the point at which we give up on handling the error, and begin propagating it.

Structs§

BadJson
Error when user JSON is missing fields
EventNotFound
FeatureNotImplemented
A feature that has not been implemented.
Forbidden
InternalServerError
Represents an unrecoverable error
NotJson
Error for when user sends us invalid JSON
RoomNotFound
Unauthorized

Enums§

InputJsonError
Error type that may occur when working with user-provided JSON.

Traits§

MatrixApiError
Trait for errors that can be converted into matrix errors
ResultExt
Extension trait for Result that allows us to handle unrecoverable errors

Functions§

create_custom_matrix_error
Create a custom matrix error
create_matrix_error
Create a matrix error

Derive Macros§

MatrixApiError
Re-export the MatrixApiError derive macro here, so one just needs to depend on arminius-lib-component when implementing MatrixApiErrors. Implements the traits arminius_lib_component::error::MatrixApiError and [axum::response::IntoResponse] for the struct or enum. Errors can be defined on structs or on enums