about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-01-11T17·50+0200
committerclbot <clbot@tvl.fyi>2024-01-12T09·22+0000
commit9cdb5e17a440bd7b88c6b36c64c29f8460af2176 (patch)
tree6008df99993a860f806f5dba26ae71ef790516a2 /tvix/eval/src
parentc806ee0eb898215359fdc80010f779b3582248d1 (diff)
fix(tvix/eval): fix JSON error types r/7369
The error message is misleading. The errors we return can happen both
during serialization or deserialization, though the messages suggested
the latter only.

Change-Id: I2dafe17ec78ee75cab5937a3a81540fda3175eac
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10603
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/errors.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs
index 4ba93a0aab..1bd2e47e93 100644
--- a/tvix/eval/src/errors.rs
+++ b/tvix/eval/src/errors.rs
@@ -163,8 +163,8 @@ pub enum ErrorKind {
         error: Rc<io::Error>,
     },
 
-    /// Errors converting JSON to a value
-    FromJsonError(String),
+    /// Errors parsing JSON, or serializing as JSON.
+    JsonError(String),
 
     /// Nix value that can not be serialised to JSON.
     NotSerialisableToJson(&'static str),
@@ -263,7 +263,7 @@ impl From<io::Error> for ErrorKind {
 impl From<serde_json::Error> for ErrorKind {
     fn from(err: serde_json::Error) -> Self {
         // Can't just put the `serde_json::Error` in the ErrorKind since it doesn't impl `Clone`
-        Self::FromJsonError(format!("error in JSON serialization: {err}"))
+        Self::JsonError(err.to_string())
     }
 }
 
@@ -444,8 +444,8 @@ to a missing value in the attribute set(s) included via `with`."#,
                 write!(f, "{error}")
             }
 
-            ErrorKind::FromJsonError(msg) => {
-                write!(f, "Error converting JSON to a Nix value: {msg}")
+            ErrorKind::JsonError(msg) => {
+                write!(f, "Error converting JSON to a Nix value or back: {msg}")
             }
 
             ErrorKind::NotSerialisableToJson(_type) => {
@@ -771,7 +771,7 @@ impl Error {
             | ErrorKind::ImportParseError { .. }
             | ErrorKind::ImportCompilerError { .. }
             | ErrorKind::IO { .. }
-            | ErrorKind::FromJsonError(_)
+            | ErrorKind::JsonError(_)
             | ErrorKind::NotSerialisableToJson(_)
             | ErrorKind::FromTomlError(_)
             | ErrorKind::Xml(_)
@@ -811,7 +811,7 @@ impl Error {
             ErrorKind::ImportParseError { .. } => "E027",
             ErrorKind::ImportCompilerError { .. } => "E028",
             ErrorKind::IO { .. } => "E029",
-            ErrorKind::FromJsonError { .. } => "E030",
+            ErrorKind::JsonError { .. } => "E030",
             ErrorKind::UnexpectedArgument { .. } => "E031",
             ErrorKind::RelativePathResolution(_) => "E032",
             ErrorKind::DivisionByZero => "E033",