Make client error serializable (#1992)
This commit is contained in:
parent
cdf97fcb96
commit
53d8e9c628
3 changed files with 21 additions and 1 deletions
|
@ -4,6 +4,7 @@ use crate::sql::Edges;
|
|||
use crate::sql::Object;
|
||||
use crate::sql::Thing;
|
||||
use crate::sql::Value;
|
||||
use serde::Serialize;
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
use thiserror::Error;
|
||||
|
@ -200,3 +201,12 @@ impl From<pharos::PharErr> for crate::Error {
|
|||
Self::Api(Error::Ws(error.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for Error {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
serializer.serialize_str(self.to_string().as_str())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ pub mod error {
|
|||
}
|
||||
|
||||
/// An error originating from the SurrealDB client library
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
#[derive(Debug, thiserror::Error, serde::Serialize)]
|
||||
pub enum Error {
|
||||
/// An error with an embedded storage engine
|
||||
#[error("{0}")]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use base64::DecodeError as Base64Error;
|
||||
use jsonwebtoken::errors::Error as JWTError;
|
||||
use reqwest::Error as ReqwestError;
|
||||
use serde::Serialize;
|
||||
use serde_cbor::error::Error as CborError;
|
||||
use serde_json::error::Error as JsonError;
|
||||
use serde_pack::encode::Error as PackError;
|
||||
|
@ -82,3 +83,12 @@ impl From<surrealdb::error::Db> for Error {
|
|||
Error::Db(error.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for Error {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
serializer.serialize_str(self.to_string().as_str())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue