query_pull_traits/errors.rs
1// Copyright 2018 Mozilla
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4// this file except in compliance with the License. You may obtain a copy of the
5// License at http://www.apache.org/licenses/LICENSE-2.0
6// Unless required by applicable law or agreed to in writing, software distributed
7// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
8// CONDITIONS OF ANY KIND, either express or implied. See the License for the
9// specific language governing permissions and limitations under the License.
10
11use std;
12// To refer to std::result::Result.
13
14use thiserror::Error;
15
16use db_traits::errors::DbError;
17
18use core_traits::Entid;
19
20pub type Result<T> = std::result::Result<T, PullError>;
21
22#[derive(Debug, Error)]
23pub enum PullError {
24 #[error("attribute {0:?} has no name")]
25 UnnamedAttribute(Entid),
26
27 #[error(":db/id repeated")]
28 RepeatedDbId,
29
30 #[error("{0}")]
31 DbError(DbError),
32}
33
34impl From<DbError> for PullError {
35 fn from(error: DbError) -> PullError {
36 PullError::DbError(error)
37 }
38}