runmat_runtime/
runtime_error.rs1pub use runmat_async::{
2 runtime_error as build_runtime_error, CallFrame, ErrorContext, RuntimeError,
3 RuntimeErrorBuilder,
4};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum ReplayErrorKind {
8 UnsupportedSchema,
9 PayloadTooLarge,
10 DecodeFailed,
11 ImportRejected,
12}
13
14impl ReplayErrorKind {
15 pub fn identifier(self) -> &'static str {
16 match self {
17 Self::UnsupportedSchema => "RunMat:ReplayUnsupportedSchema",
18 Self::PayloadTooLarge => "RunMat:ReplayPayloadTooLarge",
19 Self::DecodeFailed => "RunMat:ReplayDecodeFailed",
20 Self::ImportRejected => "RunMat:ReplayImportRejected",
21 }
22 }
23}
24
25pub fn replay_error(kind: ReplayErrorKind, message: impl Into<String>) -> RuntimeError {
26 build_runtime_error(message)
27 .with_builtin("replay")
28 .with_identifier(kind.identifier())
29 .build()
30}
31
32pub fn replay_error_with_source(
33 kind: ReplayErrorKind,
34 message: impl Into<String>,
35 source: impl std::error::Error + Send + Sync + 'static,
36) -> RuntimeError {
37 build_runtime_error(message)
38 .with_builtin("replay")
39 .with_identifier(kind.identifier())
40 .with_source(source)
41 .build()
42}