Skip to content

Commit 1c64a50

Browse files
committed
wip
1 parent 46812d0 commit 1c64a50

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

rust/catalyst-types/src/json_schema.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::{ops::Deref, sync::Arc};
44

5-
use jsonschema::{options, Draft, Validator};
5+
use jsonschema::{options, Draft, ValidationError, Validator};
66
use serde_json::Value;
77

88
/// Wrapper around a JSON Schema validator.
@@ -17,8 +17,8 @@ pub struct JsonSchema(Arc<Validator>);
1717
#[derive(Debug, thiserror::Error)]
1818
pub enum SchemaBuildError {
1919
/// Invalid JSON Schema error.
20-
#[error("Invalid JSON Schema")]
21-
InvalidSchema,
20+
#[error("{0}")]
21+
InvalidSchema(#[from] ValidationError<'static>),
2222
/// Undetectable JSON schema version.
2323
#[error(
2424
"Could not detect draft version and schema is not valid against Draft2020-12 or Draft7"
@@ -51,10 +51,7 @@ impl TryFrom<&Value> for JsonSchema {
5151
};
5252

5353
if let Some(draft) = draft_version {
54-
let validator = options()
55-
.with_draft(draft)
56-
.build(schema)
57-
.map_err(|_| SchemaBuildError::InvalidSchema)?;
54+
let validator = options().with_draft(draft).build(schema)?;
5855

5956
Ok(JsonSchema(validator.into()))
6057
} else {

0 commit comments

Comments
 (0)