nu_protocol/errors/
config_error.rs

1use crate::{ShellError, Span, Type};
2use miette::Diagnostic;
3use thiserror::Error;
4
5/// The errors that may occur when updating the config
6#[derive(Clone, Debug, PartialEq, Error, Diagnostic)]
7pub enum ConfigError {
8    #[error("Type mismatch at {path}")]
9    #[diagnostic(code(nu::shell::type_mismatch))]
10    TypeMismatch {
11        path: String,
12        expected: Type,
13        actual: Type,
14        #[label = "expected {expected}, but got {actual}"]
15        span: Span,
16    },
17    #[error("Invalid value for {path}")]
18    #[diagnostic(code(nu::shell::invalid_value))]
19    InvalidValue {
20        path: String,
21        valid: String,
22        actual: String,
23        #[label = "expected {valid}, but got {actual}"]
24        span: Span,
25    },
26    #[error("Unknown config option: {path}")]
27    #[diagnostic(code(nu::shell::unknown_config_option))]
28    UnknownOption {
29        path: String,
30        #[label("remove this")]
31        span: Span,
32    },
33    #[error("{path} requires a '{column}' column")]
34    #[diagnostic(code(nu::shell::missing_required_column))]
35    MissingRequiredColumn {
36        path: String,
37        column: &'static str,
38        #[label("has no '{column}' column")]
39        span: Span,
40    },
41    #[error("{path} is deprecated")]
42    #[diagnostic(
43        code(nu::shell::deprecated_config_option),
44        help("please {suggestion} instead")
45    )]
46    Deprecated {
47        path: String,
48        suggestion: &'static str,
49        #[label("deprecated")]
50        span: Span,
51    },
52    // TODO: remove this
53    #[error(transparent)]
54    #[diagnostic(transparent)]
55    ShellError(#[from] ShellError),
56}