lexa_env/
error.rs

1// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2// ┃ Copyright: (c) 2023, Mike 'PhiSyX' S. (https://github.com/PhiSyX)         ┃
3// ┃ SPDX-License-Identifier: MPL-2.0                                          ┃
4// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
5// ┃                                                                           ┃
6// ┃  This Source Code Form is subject to the terms of the Mozilla Public      ┃
7// ┃  License, v. 2.0. If a copy of the MPL was not distributed with this      ┃
8// ┃  file, You can obtain one at https://mozilla.org/MPL/2.0/.                ┃
9// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
10
11use std::any;
12
13// ---- //
14// Type //
15// ---- //
16
17type VariableName = &'static str;
18
19// ----------- //
20// Énumération //
21// ----------- //
22
23#[derive(Debug)]
24#[derive(thiserror::Error)]
25#[error(
26	"\n\t[{}]: erreur liée aux variables d'environnement. Raison: {0}",
27	any::type_name::<Self>()
28)]
29pub enum Error {
30	IO(#[from] std::io::Error),
31	/// L'analyse de la déclaration de la variable a échouée.
32	#[error("La déclaration n'a pas pu être analysée")]
33	ParseLineDeclaration,
34	/// La variable d'environnement est mal formée.
35	#[error("Impossible d'analyser la variable d'environnement « {0} ».")]
36	BadFormat(VariableName),
37	/// La variable d'environnement est manquante.
38	#[error("La variable d'environnement « {0} » est manquante.")]
39	NotFound(VariableName),
40	/// Erreur interne.
41	#[error("Erreur interne: {0}")]
42	Internal(String),
43}