Skip to content

Commit ecc8df4

Browse files
authored
Different error messages for JSON input (#501)
* Different error messages for JSON input * switching a few more errors
1 parent 4b1e57c commit ecc8df4

File tree

16 files changed

+297
-209
lines changed

16 files changed

+297
-209
lines changed

src/build_tools.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use pyo3::prelude::*;
77
use pyo3::types::{PyDict, PyList, PyString};
88
use pyo3::{intern, FromPyObject, PyErrArguments};
99

10-
use crate::errors::ValError;
10+
use crate::errors::{ErrorMode, ValError};
1111
use crate::ValidationError;
1212

1313
pub trait SchemaDict<'py> {
@@ -140,7 +140,7 @@ impl SchemaError {
140140
match error {
141141
ValError::LineErrors(raw_errors) => {
142142
let line_errors = raw_errors.into_iter().map(|e| e.into_py(py)).collect();
143-
let validation_error = ValidationError::new(line_errors, "Schema".to_object(py));
143+
let validation_error = ValidationError::new(line_errors, "Schema".to_object(py), ErrorMode::Python);
144144
let schema_error = SchemaError(SchemaErrorEnum::ValidationError(validation_error));
145145
match Py::new(py, schema_error) {
146146
Ok(err) => PyErr::from_value(err.into_ref(py)),

src/errors/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod value_exception;
88

99
pub use self::line_error::{InputValue, ValError, ValLineError, ValResult};
1010
pub use self::location::LocItem;
11-
pub use self::types::{list_all_errors, ErrorType};
11+
pub use self::types::{list_all_errors, ErrorMode, ErrorType};
1212
pub use self::validation_exception::ValidationError;
1313
pub use self::value_exception::{PydanticCustomError, PydanticKnownError, PydanticOmit};
1414

0 commit comments

Comments
 (0)