Skip to content

Commit

Permalink
Different error messages for JSON input (#501)
Browse files Browse the repository at this point in the history
* Different error messages for JSON input

* switching a few more errors
  • Loading branch information
samuelcolvin authored Mar 30, 2023
1 parent 4b1e57c commit ecc8df4
Show file tree
Hide file tree
Showing 16 changed files with 297 additions and 209 deletions.
4 changes: 2 additions & 2 deletions src/build_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pyo3::prelude::*;
use pyo3::types::{PyDict, PyList, PyString};
use pyo3::{intern, FromPyObject, PyErrArguments};

use crate::errors::ValError;
use crate::errors::{ErrorMode, ValError};
use crate::ValidationError;

pub trait SchemaDict<'py> {
Expand Down Expand Up @@ -140,7 +140,7 @@ impl SchemaError {
match error {
ValError::LineErrors(raw_errors) => {
let line_errors = raw_errors.into_iter().map(|e| e.into_py(py)).collect();
let validation_error = ValidationError::new(line_errors, "Schema".to_object(py));
let validation_error = ValidationError::new(line_errors, "Schema".to_object(py), ErrorMode::Python);
let schema_error = SchemaError(SchemaErrorEnum::ValidationError(validation_error));
match Py::new(py, schema_error) {
Ok(err) => PyErr::from_value(err.into_ref(py)),
Expand Down
2 changes: 1 addition & 1 deletion src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod value_exception;

pub use self::line_error::{InputValue, ValError, ValLineError, ValResult};
pub use self::location::LocItem;
pub use self::types::{list_all_errors, ErrorType};
pub use self::types::{list_all_errors, ErrorMode, ErrorType};
pub use self::validation_exception::ValidationError;
pub use self::value_exception::{PydanticCustomError, PydanticKnownError, PydanticOmit};

Expand Down
Loading

0 comments on commit ecc8df4

Please sign in to comment.