aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-11-15 19:12:40 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-11-15 19:12:40 +0100
commitf4e23120e5d55de201eb4f21c5340950d472b11c (patch)
tree2ecb2ea50b59087389f159b49c2669862bd7c0ac /src/main.rs
parent0d0b11a9ae84e5df9f77f2d2340fa80c32aebcd8 (diff)
prettify error messages
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 287009f..bb62131 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,3 @@
-use rustkrazy_admind::{Error, Result};
-
use std::fs::{self, File, OpenOptions};
use std::io::{self, BufReader, Write};
@@ -15,12 +13,33 @@ use rustls::{Certificate, PrivateKey, ServerConfig};
use rustls_pemfile::{certs, pkcs8_private_keys};
use serde::Deserialize;
use sysinfo::{Pid, ProcessExt, Signal, System, SystemExt};
+use thiserror::Error;
#[allow(non_upper_case_globals)]
const KiB: usize = 1024;
#[allow(non_upper_case_globals)]
const MiB: usize = 1024 * KiB;
+#[derive(Debug, Error)]
+pub enum Error {
+ #[error("can't find disk device")]
+ NoDiskDev,
+ #[error("no private keys found in file")]
+ NoPrivateKeys,
+ #[error("no rootfs set in active cmdline")]
+ RootdevUnset,
+
+ #[error("io error: {0}")]
+ Io(#[from] io::Error),
+
+ #[error("actix_web error: {0}")]
+ ActixWeb(#[from] actix_web::Error),
+ #[error("rustls error: {0}")]
+ Rustls(#[from] rustls::Error),
+}
+
+pub type Result<T> = std::result::Result<T, Error>;
+
#[derive(Clone, Debug, Deserialize)]
struct DataRequest {
path: String,