use thiserror::Error;
use crate::schema::SchemaId;
#[derive(Clone, Error, Debug)]
pub enum SchemaNameError {
#[error("Schema name contains too many or invalid characters")]
MalformedSchemaName,
}
impl Copy for SchemaNameError {}
#[derive(Clone, Error, Debug)]
pub enum SchemaDescriptionError {
#[error("Schema description contains more than 256 characters")]
TooLongSchemaDescription,
}
#[derive(Clone, Error, Debug)]
pub enum SchemaFieldError {
#[error("Schema field found with invalid name")]
MalformedSchemaFieldName,
#[error("Schema fields contains more than 1024 fields")]
TooManyFields,
#[error("Schema fields must contain at least one entry")]
ZeroFields,
#[error("Schema fields cannot contain duplicate field names")]
DuplicateFields,
}
#[derive(Error, Debug)]
pub enum SchemaIdError {
#[error("malformed schema id `{0}`: {1}")]
MalformedSchemaId(String, String),
#[error("application schema id is missing a name: {0}")]
MissingApplicationSchemaName(String),
#[error("unsupported system schema: {0}")]
UnknownSystemSchema(String),
#[error("encountered invalid hash while parsing application schema id: {0}")]
HashError(#[from] crate::hash::error::HashError),
#[error("encountered invalid document view id while parsing application schema id: {0}")]
DocumentViewIdError(#[from] crate::document::error::DocumentViewIdError),
#[error("encountered invalid hash while parsing application schema id: {0}")]
OperationIdError(#[from] crate::operation::error::OperationIdError),
}
#[derive(Error, Debug)]
pub enum SchemaError {
#[error("invalid fields found for this schema")]
InvalidFields,
#[error("dynamic redefinition of system schema {0}, use `Schema::get_system` instead")]
DynamicSystemSchema(SchemaId),
#[error(transparent)]
SchemaIdError(#[from] SchemaIdError),
#[error(transparent)]
SchemaNameError(#[from] SchemaNameError),
#[error(transparent)]
SchemaDescriptionError(#[from] SchemaDescriptionError),
#[error(transparent)]
SchemaFieldsError(#[from] SchemaFieldError),
}
#[derive(Error, Debug)]
pub enum FieldTypeError {
#[error("invalid field type '{0}'")]
InvalidFieldType(String),
#[error(transparent)]
RelationSchemaReference(#[from] SchemaIdError),
}