@@ -6,6 +6,9 @@ use std::process::{self, ExitCode, Termination};
66
77use url:: Url ;
88
9+ use crate :: prop;
10+ use crate :: prop:: ParsePropertyError ;
11+
912pub trait Error : StdError + Termination { }
1013
1114pub enum FireError {
@@ -17,6 +20,7 @@ pub enum FireError {
1720 GenericIO ( String ) ,
1821 TemplateRendering ,
1922 TemplateKey ( String ) ,
23+ Environment ( ParsePropertyError ) ,
2024 Other ( String ) ,
2125}
2226
@@ -37,6 +41,12 @@ impl Display for FireError {
3741 FireError :: NoReadPermission ( path) => format ! ( "No permission to read file {:?}" , path. clone( ) ) ,
3842 FireError :: TemplateRendering => String :: from ( "Unable to render request from template" ) ,
3943 FireError :: TemplateKey ( key) => format ! ( "Unable to render request due to missing value for key {key}" ) ,
44+ FireError :: Environment ( err) => match err {
45+ prop:: ParsePropertyError :: Entry ( entry) => format ! ( "Invalid entry in environments file: {entry}" ) ,
46+ prop:: ParsePropertyError :: Key ( key) => format ! ( "Invalid key in environments file: {key}" ) ,
47+ prop:: ParsePropertyError :: Value ( value) => format ! ( "Invalid value in environments file: {value}" ) ,
48+ prop:: ParsePropertyError :: File ( file) => format ! ( "Invalid environments file: {file}" ) ,
49+ } ,
4050 FireError :: Other ( err) => format ! ( "Error: {err}" ) ,
4151 } ;
4252
@@ -55,6 +65,7 @@ impl Termination for FireError {
5565 FireError :: GenericIO ( _) => ExitCode :: from ( 8 ) ,
5666 FireError :: TemplateKey ( _) => ExitCode :: from ( 9 ) ,
5767 FireError :: TemplateRendering => ExitCode :: from ( 10 ) ,
68+ FireError :: Environment ( _) => ExitCode :: from ( 11 ) ,
5869 FireError :: Other ( _) => ExitCode :: from ( 1 ) ,
5970 }
6071 }
0 commit comments