change errors codes

This commit is contained in:
marin postma 2021-06-22 11:58:01 +02:00
parent 905ace3e13
commit d0ef1ef174
No known key found for this signature in database
GPG Key ID: 6088B7721C3E39F9

View File

@ -103,7 +103,6 @@ impl ErrorCode for MilliError<'_> {
milli::Error::UserError(ref error) => { milli::Error::UserError(ref error) => {
match error { match error {
// TODO: wait for spec for new error codes. // TODO: wait for spec for new error codes.
UserError::AttributeLimitReached
| UserError::Csv(_) | UserError::Csv(_)
| UserError::SerdeJson(_) | UserError::SerdeJson(_)
| UserError::MaxDatabaseSizeReached | UserError::MaxDatabaseSizeReached
@ -112,6 +111,7 @@ impl ErrorCode for MilliError<'_> {
| UserError::InvalidStoreFile | UserError::InvalidStoreFile
| UserError::NoSpaceLeftOnDevice | UserError::NoSpaceLeftOnDevice
| UserError::DocumentLimitReached => Code::Internal, | UserError::DocumentLimitReached => Code::Internal,
UserError::AttributeLimitReached => Code::MaxFieldsLimitExceeded,
UserError::InvalidFilter(_) => Code::Filter, UserError::InvalidFilter(_) => Code::Filter,
UserError::InvalidFilterAttribute(_) => Code::Filter, UserError::InvalidFilterAttribute(_) => Code::Filter,
UserError::MissingDocumentId { .. } => Code::MissingDocumentId, UserError::MissingDocumentId { .. } => Code::MissingDocumentId,
@ -146,10 +146,11 @@ impl ErrorCode for PayloadError {
fn error_code(&self) -> Code { fn error_code(&self) -> Code {
match self { match self {
PayloadError::Json(err) => match err { PayloadError::Json(err) => match err {
JsonPayloadError::Deserialize(_) => Code::BadRequest,
JsonPayloadError::Overflow => Code::PayloadTooLarge, JsonPayloadError::Overflow => Code::PayloadTooLarge,
JsonPayloadError::ContentType => Code::UnsupportedMediaType, JsonPayloadError::ContentType => Code::UnsupportedMediaType,
JsonPayloadError::Payload(_) => Code::BadRequest, JsonPayloadError::Payload(aweb::error::PayloadError::Overflow) => Code::PayloadTooLarge,
JsonPayloadError::Deserialize(_)
| JsonPayloadError::Payload(_) => Code::BadRequest,
JsonPayloadError::Serialize(_) => Code::Internal, JsonPayloadError::Serialize(_) => Code::Internal,
_ => Code::Internal, _ => Code::Internal,
}, },