From bcaa3011e04a56853ea209282e81d36443e6618a Mon Sep 17 00:00:00 2001 From: AshleySchaeffer <73253727+AshleySchaeffer@users.noreply.github.com> Date: Mon, 24 Oct 2022 15:40:56 +0100 Subject: [PATCH 1/4] Public ErrorCode getter for Error type Added a public getter to the ErrorCode enum to facilitate more verbose error handling. --- src/error.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/error.rs b/src/error.rs index 1875ef08b..85d1720d7 100644 --- a/src/error.rs +++ b/src/error.rs @@ -104,6 +104,12 @@ impl Error { pub fn is_eof(&self) -> bool { self.classify() == Category::Eof } + + /// Returns a reference to the ErrorCode that represents the specific cause + /// of this error. + pub fn error_core(&self) -> &ErrorCode { + &self.err.code + } } /// Categorizes the cause of a `serde_json::Error`. From 5bc7d483f251b81f76f18a20b305d3e7e109df29 Mon Sep 17 00:00:00 2001 From: AshleySchaeffer <73253727+AshleySchaeffer@users.noreply.github.com> Date: Mon, 24 Oct 2022 15:42:52 +0100 Subject: [PATCH 2/4] Fixed typo --- src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index 85d1720d7..22ad955e0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -107,7 +107,7 @@ impl Error { /// Returns a reference to the ErrorCode that represents the specific cause /// of this error. - pub fn error_core(&self) -> &ErrorCode { + pub fn error_code(&self) -> &ErrorCode { &self.err.code } } From 14605ed0e181cb24a1d4ed0d3d4f8232bf1cad15 Mon Sep 17 00:00:00 2001 From: AshleySchaeffer <73253727+AshleySchaeffer@users.noreply.github.com> Date: Mon, 24 Oct 2022 15:45:50 +0100 Subject: [PATCH 3/4] Update error.rs Made ErrorCode enum public --- src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index 22ad955e0..8c9d680b2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -184,7 +184,7 @@ struct ErrorImpl { column: usize, } -pub(crate) enum ErrorCode { +pub enum ErrorCode { /// Catchall for syntax error messages Message(Box), From a1e8d7d6439b3dab624030660e5e875d261654bf Mon Sep 17 00:00:00 2001 From: AshleySchaeffer <73253727+AshleySchaeffer@users.noreply.github.com> Date: Mon, 24 Oct 2022 15:49:19 +0100 Subject: [PATCH 4/4] Added old docs to ErrorCode enum --- src/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/error.rs b/src/error.rs index 8c9d680b2..53922f904 100644 --- a/src/error.rs +++ b/src/error.rs @@ -184,6 +184,7 @@ struct ErrorImpl { column: usize, } +/// The errors that can arise while parsing a JSON stream. pub enum ErrorCode { /// Catchall for syntax error messages Message(Box),