feat: add thiserror annotations to error
This commit is contained in:
parent
1d746430d2
commit
f47fd24232
3 changed files with 13 additions and 1 deletions
|
|
@ -7,3 +7,4 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
bimap = "0.6.3"
|
||||
thiserror = "1.0.50"
|
||||
|
|
|
|||
|
|
@ -1,17 +1,27 @@
|
|||
use thiserror::Error;
|
||||
use crate::internals::row::ColumnPosition;
|
||||
use crate::schema::{ColumnName, TableName};
|
||||
use crate::operation::InsertionValues;
|
||||
use crate::type_system::{DbType, Uuid, Value};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
#[error("table {0} does not exist")]
|
||||
TableDoesNotExist(TableName),
|
||||
#[error("column {1} of table {0} does not exist")]
|
||||
ColumnDoesNotExist(TableName, ColumnName),
|
||||
#[error("column position {1} of table {0} does not exist")]
|
||||
ColumnPositionDoesNotExist(TableName, ColumnPosition),
|
||||
#[error("column {1} of table {0} has unexpected type {2:?} and value {3:?}")]
|
||||
ValueDoesNotMatchExpectedType(TableName, ColumnName, DbType, Value),
|
||||
#[error("table {0} already contains row with id {1}")]
|
||||
AttemptingToInsertAlreadyPresentId(TableName, Uuid),
|
||||
#[error("table {0} is missing annotation for column {1}")]
|
||||
MissingTypeAnnotationOfColumn(TableName, ColumnPosition),
|
||||
#[error("table {0} is missing column {1} in insert values {2:?}")]
|
||||
MissingColumnInInsertValues(TableName, ColumnName, InsertionValues),
|
||||
#[error("table {0} has mismatch between insert values {1:?} and columns")]
|
||||
MismatchBetweenInsertValuesAndColumns(TableName, InsertionValues),
|
||||
#[error("table {0} cannot be indexed on column {1}")]
|
||||
AttemptToIndexNonIndexableColumn(TableName, ColumnName),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue