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