Compare commits
3 Commits
3640039168
...
a6b635fef0
| Author | SHA1 | Date | |
|---|---|---|---|
|
a6b635fef0
|
|||
|
3c58192957
|
|||
|
c438e60e24
|
15
src/main.rs
15
src/main.rs
@@ -38,12 +38,19 @@ fn Home() -> Element {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
fn tracing_setup() {
|
||||
#[cfg(debug_assertions)]
|
||||
dioxus::logger::init(tracing::Level::DEBUG).expect("Failed to initialize tracing logger");
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
server::main();
|
||||
|
||||
#[cfg(not(feature = "server"))]
|
||||
fn main() {
|
||||
tracing_setup();
|
||||
dioxus::launch(App);
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
fn main() {
|
||||
tracing_setup();
|
||||
server::main()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use crate::App;
|
||||
|
||||
pub fn main() {
|
||||
#[cfg(feature = "server")]
|
||||
if let Err(e) = dotenvy::dotenv() {
|
||||
tracing::warn!("Error reading .env: {e}");
|
||||
}
|
||||
|
||||
dioxus::launch(App);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ impl fmt::Display for ErrorLocation {
|
||||
}
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, thiserror::Error)]
|
||||
pub struct Error {
|
||||
#[source]
|
||||
@@ -247,9 +249,9 @@ pub trait Contextualize<R> {
|
||||
fn err_context(self, context: impl Into<String>) -> R;
|
||||
}
|
||||
|
||||
impl<T, E: Into<Error>> Contextualize<Result<T, Error>> for Result<T, E> {
|
||||
impl<T, E: Into<Error>> Contextualize<Result<T>> for std::result::Result<T, E> {
|
||||
#[track_caller]
|
||||
fn err_context(self, context: impl Into<String>) -> Result<T, Error> {
|
||||
fn err_context(self, context: impl Into<String>) -> Result<T> {
|
||||
// Closures can't (currently) `track_caller`, so a simple map_err doesn't work
|
||||
// See https://github.com/rust-lang/rust/issues/87417
|
||||
match self {
|
||||
@@ -259,16 +261,16 @@ impl<T, E: Into<Error>> Contextualize<Result<T, Error>> for Result<T, E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Contextualize<Result<T, Error>> for Option<T> {
|
||||
impl<T> Contextualize<Result<T>> for Option<T> {
|
||||
#[track_caller]
|
||||
fn err_context(self, context: impl Into<String>) -> Result<T, Error> {
|
||||
fn err_context(self, context: impl Into<String>) -> Result<T> {
|
||||
self.ok_or(Error::new_here(ErrorType::Error(context.into())))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E: Into<Error>> Contextualize<Result<T, Error>> for E {
|
||||
impl<T, E: Into<Error>> Contextualize<Result<T>> for E {
|
||||
#[track_caller]
|
||||
fn err_context(self, context: impl Into<String>) -> Result<T, Error> {
|
||||
fn err_context(self, context: impl Into<String>) -> Result<T> {
|
||||
Err(self.into().with_context(context))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user