uni_plugin_rhai/error.rs
1//! Error types for the Rhai loader.
2
3use thiserror::Error;
4
5/// Errors specific to the Rhai loader.
6///
7/// Mirrors `uni_plugin_extism::ExtismError` in shape so the three
8/// loaders surface comparable failure modes.
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum RhaiError {
12 /// The supplied Rhai source failed to compile, or did not declare a
13 /// `uni_manifest()` function returning the expected shape.
14 #[error("rhai plugin: invalid source or manifest: {0}")]
15 InvalidPlugin(String),
16
17 /// The plugin's declared manifest did not pass validation
18 /// (unknown ABI, missing required fields, unknown type names).
19 #[error("rhai plugin manifest invalid: {0}")]
20 ManifestInvalid(String),
21
22 /// Rhai source failed to parse — the engine could not produce an AST.
23 /// The wrapped string includes Rhai's file:line:col context.
24 #[error("rhai parse failed: {0}")]
25 ParseFailed(String),
26
27 /// Runtime error during script execution (type mismatch, arithmetic
28 /// error, host-fn panic). Wraps Rhai's runtime error message.
29 #[error("rhai runtime error: {0}")]
30 RuntimeError(String),
31
32 /// Conversion between Rhai `Dynamic` and Arrow `ScalarValue` /
33 /// `ArrayRef` failed (unsupported type, precision loss, null handling).
34 #[error("rhai <-> arrow conversion failure: {0}")]
35 Conversion(String),
36
37 /// Internal / unexpected error.
38 #[error("uni-plugin-rhai internal error: {0}")]
39 Internal(String),
40}