Bootstrap schema validation for simple constants.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
use super::schema;
|
||||
use super::{
|
||||
definitions::Reference,
|
||||
schema::{self, Schema},
|
||||
};
|
||||
use aiken_lang::ast::Span;
|
||||
use miette::{Diagnostic, NamedSource};
|
||||
use owo_colors::{OwoColorize, Stream::Stdout};
|
||||
@@ -43,6 +46,30 @@ pub enum Error {
|
||||
blueprint_apply_command = "blueprint apply".if_supports_color(Stdout, |s| s.purple()),
|
||||
))]
|
||||
ParameterizedValidator { n: usize },
|
||||
|
||||
#[error("I failed to infer what should be the schema of a given parameter to apply.")]
|
||||
#[diagnostic(code("aiken:blueprint::apply::malformed::argument"))]
|
||||
#[diagnostic(help(
|
||||
"I couldn't figure out the schema corresponding to a term you've given. Here's a possible hint about why I failed: {hint}"
|
||||
))]
|
||||
UnableToInferArgumentSchema { hint: String },
|
||||
|
||||
#[error("I couldn't find a definition corresponding to a reference.")]
|
||||
#[diagnostic(code("aiken::blueprint::apply::unknown::reference"))]
|
||||
#[diagnostic(help(
|
||||
"While resolving a schema definition, I stumble upon an unknown reference:\n\n {reference}\n\nThis is unfortunate, but signals that either the reference is invalid or that the correspond schema definition is missing.",
|
||||
reference = reference.as_json_pointer()
|
||||
))]
|
||||
UnresolvedSchemaReference { reference: Reference },
|
||||
|
||||
#[error("I caught a parameter application that seems off.")]
|
||||
#[diagnostic(code("aiken::blueprint::apply::mismatch"))]
|
||||
#[diagnostic(help(
|
||||
"When applying parameters to a validator, I control that the shape of the parameter you give me matches what is specified in the blueprint. Unfortunately, schemas didn't match in this case.\n\nI am expecting the following:\n\n{}But I've inferred the following schema from your input:\n\n{}",
|
||||
serde_json::to_string_pretty(&expected).unwrap().if_supports_color(Stdout, |s| s.green()),
|
||||
serde_json::to_string_pretty(&inferred).unwrap().if_supports_color(Stdout, |s| s.red()),
|
||||
))]
|
||||
SchemaMismatch { expected: Schema, inferred: Schema },
|
||||
}
|
||||
|
||||
unsafe impl Send for Error {}
|
||||
|
||||
Reference in New Issue
Block a user