nu_protocol/errors/
config_error.rs

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use crate::{ShellError, Span, Type};
use miette::Diagnostic;
use thiserror::Error;

/// The errors that may occur when updating the config
#[derive(Clone, Debug, PartialEq, Error, Diagnostic)]
pub enum ConfigError {
    #[error("Type mismatch at {path}")]
    #[diagnostic(code(nu::shell::type_mismatch))]
    TypeMismatch {
        path: String,
        expected: Type,
        actual: Type,
        #[label = "expected {expected}, but got {actual}"]
        span: Span,
    },
    #[error("Invalid value for {path}")]
    #[diagnostic(code(nu::shell::invalid_value))]
    InvalidValue {
        path: String,
        valid: String,
        actual: String,
        #[label = "expected {valid}, but got {actual}"]
        span: Span,
    },
    #[error("Unknown config option: {path}")]
    #[diagnostic(code(nu::shell::unknown_config_option))]
    UnknownOption {
        path: String,
        #[label("remove this")]
        span: Span,
    },
    #[error("{path} requires a '{column}' column")]
    #[diagnostic(code(nu::shell::missing_required_column))]
    MissingRequiredColumn {
        path: String,
        column: &'static str,
        #[label("has no '{column}' column")]
        span: Span,
    },
    #[error("{path} is deprecated")]
    #[diagnostic(
        code(nu::shell::deprecated_config_option),
        help("please {suggestion} instead")
    )]
    Deprecated {
        path: String,
        suggestion: &'static str,
        #[label("deprecated")]
        span: Span,
    },
    // TODO: remove this
    #[error(transparent)]
    #[diagnostic(transparent)]
    ShellError(#[from] ShellError),
}