Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libsql-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
http-body = "0.4"
url = { version = "2.3", features = ["serde"] }
uuid = { version = "1.3", features = ["v4", "serde"] }
moka = { version = "0.12.1", features = ["future"] }

[dev-dependencies]
arbitrary = { version = "1.3.0", features = ["derive_arbitrary"] }
Expand Down
14 changes: 12 additions & 2 deletions libsql-server/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ pub enum Error {
UrlParseError(#[from] url::ParseError),
#[error("Namespace store has shutdown")]
NamespaceStoreShutdown,
// This is for errors returned by moka
#[error(transparent)]
Ref(#[from] std::sync::Arc<Self>),
}

trait ResponseError: std::error::Error {
Expand All @@ -105,6 +108,12 @@ trait ResponseError: std::error::Error {
impl ResponseError for Error {}

impl IntoResponse for Error {
fn into_response(self) -> axum::response::Response {
(&self).into_response()
}
}

impl IntoResponse for &Error {
fn into_response(self) -> axum::response::Response {
use Error::*;

Expand Down Expand Up @@ -150,6 +159,7 @@ impl IntoResponse for Error {
PrimaryStreamInterupted => self.format_err(StatusCode::INTERNAL_SERVER_ERROR),
UrlParseError(_) => self.format_err(StatusCode::BAD_REQUEST),
NamespaceStoreShutdown => self.format_err(StatusCode::SERVICE_UNAVAILABLE),
Ref(this) => this.as_ref().into_response(),
}
}
}
Expand Down Expand Up @@ -224,7 +234,7 @@ pub enum LoadDumpError {

impl ResponseError for LoadDumpError {}

impl IntoResponse for LoadDumpError {
impl IntoResponse for &LoadDumpError {
fn into_response(self) -> axum::response::Response {
use LoadDumpError::*;

Expand All @@ -244,7 +254,7 @@ impl IntoResponse for LoadDumpError {

impl ResponseError for ForkError {}

impl IntoResponse for ForkError {
impl IntoResponse for &ForkError {
fn into_response(self) -> axum::response::Response {
match self {
ForkError::Internal(_)
Expand Down
Loading