Some checks failed
actionlint check / actionlint check (pull_request) Successful in 7s
checkov check / checkov check (pull_request) Successful in 53s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 4s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 2s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 6s
GitLeaks check / GitLeaks check (pull_request) Successful in 7s
hadolint check / hadolint check (pull_request) Successful in 9s
htmlhint check / htmlhint check (pull_request) Successful in 9s
markdownlint check / markdownlint check (pull_request) Successful in 9s
Prettier check / Prettier check (pull_request) Successful in 10s
Rust check / Rust check (pull_request) Failing after 7m40s
ShellCheck check / ShellCheck check (pull_request) Successful in 12s
Stylelint check / Stylelint check (pull_request) Successful in 11s
yamllint check / yamllint check (pull_request) Successful in 14s
37 lines
879 B
Rust
37 lines
879 B
Rust
use serde::{Deserialize, Serialize};
|
|
use std::fmt::Display;
|
|
use std::str::FromStr;
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
pub enum Error {
|
|
ServerInternal,
|
|
}
|
|
|
|
#[cfg(feature = "server")]
|
|
impl From<diesel::result::Error> for Error {
|
|
fn from(_: diesel::result::Error) -> Self {
|
|
Self::ServerInternal
|
|
}
|
|
}
|
|
|
|
// has to be implemented for Dioxus server functions
|
|
impl Display for Error {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Self::ServerInternal => write!(f, "internal server error"),
|
|
}
|
|
}
|
|
}
|
|
|
|
// has to be implemented for Dioxus server functions
|
|
impl FromStr for Error {
|
|
type Err = ();
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
Ok(match s {
|
|
"internal server error" => Self::ServerInternal,
|
|
_ => return Err(()),
|
|
})
|
|
}
|
|
}
|