about summary refs log tree commit diff
path: root/splorm/src/runtime_error.rs
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2026-09-26 19:40:24 -0500
committergennyble <gen@nyble.dev>2026-09-26 19:40:24 -0500
commit9cdd743e0f6a7b81da201d0467b262e7f23a67a7 (patch)
tree7744cda73c0eb826a4aa7f5e53ae340d59d90d4a /splorm/src/runtime_error.rs
parent5d8c6ead334146ef20910559251b73dbb45e3f63 (diff)
splorm uses breakdown in quark
Diffstat (limited to 'splorm/src/runtime_error.rs')
-rw-r--r--splorm/src/runtime_error.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/splorm/src/runtime_error.rs b/splorm/src/runtime_error.rs
index 2d9e43a..d1e624a 100644
--- a/splorm/src/runtime_error.rs
+++ b/splorm/src/runtime_error.rs
@@ -17,6 +17,7 @@ use axum::{
 use camino::Utf8PathBuf;
 use gny::sternum::Sternum;
 use somethings::DatabaseError;
+use wikarden::WikError;
 
 use crate::QueryParseError;
 
@@ -68,6 +69,8 @@ pub enum RuntimeError {
 	GenericBadRequest { reason: Cow<'static, str> },
 	/// Error interacting with the database
 	DatabaseError { source: DatabaseError },
+	/// An error from wikarden
+	WikiError { source: WikError },
 	/// failed authentication
 	AuthenticationFailed { name: String },
 	/// A [`SessionID`] was invalid
@@ -164,6 +167,11 @@ impl RuntimeError {
 			Self::GenericBadRequest { .. } => 400,
 			Self::IncompleteForm { .. } => 400,
 			Self::DatabaseError { .. } => 500,
+			Self::WikiError { source } => match source {
+				WikError::IllegalPath { .. } => 404,
+				WikError::CanonicalizationFailed { .. } => 404,
+				_ => 500,
+			},
 			Self::AuthenticationFailed { .. } => 403,
 			Self::InvalidSession => 403,
 			Self::Generic403 => 403,
@@ -211,6 +219,9 @@ impl fmt::Display for RuntimeError {
 			RuntimeError::DatabaseError { source } => {
 				write!(f, "database error: {source}")
 			}
+			RuntimeError::WikiError { source } => {
+				write!(f, "wiki error: {source}")
+			}
 			RuntimeError::AuthenticationFailed { name } => {
 				write!(f, "authentication failed for '{name}'")
 			}
@@ -262,6 +273,11 @@ impl<'re> fmt::Display for PresentableRuntimeError<'re> {
 			RuntimeError::GenericBadRequest { .. } => estr!(400),
 			RuntimeError::IncompleteForm { missing_field } => estr!(400 incomplete missing_field),
 			RuntimeError::DatabaseError { .. } => estr!(500),
+			RuntimeError::WikiError { source } => match source {
+				WikError::IllegalPath { wik, .. } => estr!(404 wik),
+				WikError::CanonicalizationFailed { .. } => estr!(404),
+				_ => estr!(500),
+			},
 			RuntimeError::AuthenticationFailed { .. } => estr!(403),
 			RuntimeError::InvalidSession => estr!(403),
 			RuntimeError::Generic403 => estr!(403),
@@ -312,3 +328,9 @@ impl From<DatabaseError> for RuntimeError {
 		RuntimeError::DatabaseError { source: dbe }
 	}
 }
+
+impl From<WikError> for RuntimeError {
+	fn from(we: WikError) -> Self {
+		RuntimeError::WikiError { source: we }
+	}
+}