Skip to main content

esbuild_config_lib/
errors.rs

1use std::{error, fmt, io};
2
3#[derive(Debug)]
4pub enum EsbuildConfigError {
5    ConfigParseError,
6    ConfigPathError,
7    Io(io::Error),
8}
9impl fmt::Display for EsbuildConfigError {
10    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
11        write!(f, "An unknown error happened.")
12    }
13}
14
15#[derive(Debug)]
16pub enum ConfigPathError {
17    Io(io::Error),
18}
19impl fmt::Display for ConfigPathError {
20    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21        write!(f, "Couldn’t find or open the esbuild configuration file.")
22    }
23}
24
25#[derive(Debug)]
26pub enum ConfigParseError {
27    InvalidConfigError,
28    JsonError(json::Error),
29}
30impl fmt::Display for ConfigParseError {
31    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
32        write!(f, "Invalid esbuild configuration format.")
33    }
34}
35
36#[derive(Debug)]
37pub struct InvalidConfigError;
38impl error::Error for InvalidConfigError {}
39impl fmt::Display for InvalidConfigError {
40    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
41        write!(f, "Invalid esbuild configuration format.")
42    }
43}