surrealdb_core/sql/statements/
throw.rsuse crate::ctx::Context;
use crate::dbs::Options;
use crate::doc::CursorDoc;
use crate::err::Error;
use crate::sql::Value;
use derive::Store;
use reblessive::tree::Stk;
use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct ThrowStatement {
pub error: Value,
}
impl ThrowStatement {
pub(crate) fn writeable(&self) -> bool {
false
}
pub(crate) async fn compute(
&self,
stk: &mut Stk,
ctx: &Context,
opt: &Options,
doc: Option<&CursorDoc>,
) -> Result<Value, Error> {
Err(Error::Thrown(self.error.compute(stk, ctx, opt, doc).await?.to_raw_string()))
}
}
impl fmt::Display for ThrowStatement {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "THROW {}", self.error)
}
}