router_bridge/
error.rs

1/*!
2# Errors raised by the `router-bridge` when trying to run `javascript`.
3*/
4
5use serde::{Deserialize, Serialize};
6use thiserror::Error;
7
8#[derive(Error, Serialize, Deserialize, Debug, Clone)]
9/// An error which occurred within the bridge.
10///
11/// This does not include JS domain related errors, such as [`GraphQLError`].
12pub enum Error {
13    /// An uncaught error was raised when invoking a custom script.
14    ///
15    /// This contains the script invocation error message.
16    #[error("the deno runtime raised an error: `{0}`")]
17    DenoRuntime(String),
18    /// An uncaught error was raised when trying to serialize a parameter before sending it to the javascript worker.
19    ///
20    /// This contains the serialization error message, and the payload name.
21    #[error("couldn't serialize parameter `{name}`: `{message}`.")]
22    ParameterSerialization {
23        /// The underlying serialization error.
24        message: String,
25        /// The name of the parameter we tried to serialize.
26        name: String,
27    },
28
29    /// An uncaught error was raised when trying to deserialize a payload.
30    ///
31    /// This contains the deserialization error message, and the payload.
32    #[error("couldn't deserialize payload `{id}`: `{message}`.")]
33    ParameterDeserialization {
34        /// The underlying serialization error.
35        message: String,
36        /// The deno response id we tried to deserialize.
37        id: String,
38    },
39}