about summary refs log tree commit diff
path: root/tvix/eval/src/errors.rs
blob: d8c3ce41cc1d043b7a52c2335288de8b884ed419 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::fmt::Display;

#[derive(Debug)]
pub enum Error {
    DuplicateAttrsKey {
        key: String,
    },

    InvalidKeyType {
        given: &'static str,
    },

    AttributeNotFound {
        name: String,
    },

    TypeError {
        expected: &'static str,
        actual: &'static str,
    },

    Incomparable {
        lhs: &'static str,
        rhs: &'static str,
    },

    // Resolving a user-supplied path literal failed in some way.
    PathResolution(String),
}

impl Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        writeln!(f, "{:?}", self)
    }
}

pub type EvalResult<T> = Result<T, Error>;