@@ -25,32 +25,6 @@ pub enum Error {
2525 FilteredOut ,
2626}
2727
28- #[ derive( Debug , Error ) ]
29- pub enum ConfigurationError {
30- #[ error( "'Never' or 'Conditional' can't be used after 'Always' for path {0:?}" ) ]
31- AfterAlways ( path:: PathBuf ) ,
32- #[ error( "'Never' can't be used after 'Conditional' for path {0:?}" ) ]
33- AfterConditional ( path:: PathBuf ) ,
34- #[ error( "'Always' or 'Conditional' can't be used after 'Never' for path {0:?}" ) ]
35- AfterNever ( path:: PathBuf ) ,
36- #[ error( "'Always' can't be used multiple times for path {0:?}" ) ]
37- MultipleAlways ( path:: PathBuf ) ,
38- #[ error( "'Conditional' can't be used multiple times for path {0:?}" ) ]
39- MultipleConditional ( path:: PathBuf ) ,
40- #[ error( "'Never' can't be used multiple times for path {0:?}" ) ]
41- MultipleNever ( path:: PathBuf ) ,
42- #[ error( "'Always' can't be used with arguments for path {0:?}" ) ]
43- AlwaysWithArguments ( path:: PathBuf ) ,
44- #[ error( "'Conditional' can't be used without arguments for path {0:?}" ) ]
45- ConditionalWithoutMatch ( path:: PathBuf ) ,
46- #[ error( "'Never' can't be used with arguments for path {0:?}" ) ]
47- NeverWithArguments ( path:: PathBuf ) ,
48- #[ error( "Only relative paths for 'file' and 'output' when 'directory' is relative." ) ]
49- OnlyRelativePaths ,
50- #[ error( "Getting current directory failed: {0}" ) ]
51- CurrentWorkingDirectory ( #[ from] io:: Error ) ,
52- }
53-
5428/// FilterAndFormat is a transformation that filters and formats the compiler calls.
5529pub struct FilterAndFormat {
5630 filter : filter:: SemanticFilter ,
@@ -65,8 +39,16 @@ impl Transformation for FilterAndFormat {
6539 }
6640}
6741
42+ #[ derive( Debug , Error ) ]
43+ pub enum FilterAndFormatError {
44+ #[ error( "Semantic filter configuration error: {0}" ) ]
45+ SemanticFilter ( #[ from] filter:: SemanticFilterError ) ,
46+ #[ error( "Path formatter configuration error: {0}" ) ]
47+ PathFormatter ( #[ from] formatter:: PathFormatterError ) ,
48+ }
49+
6850impl TryFrom < & config:: Output > for FilterAndFormat {
69- type Error = ConfigurationError ;
51+ type Error = FilterAndFormatError ;
7052
7153 fn try_from ( value : & config:: Output ) -> Result < Self , Self :: Error > {
7254 match value {
@@ -130,8 +112,16 @@ mod formatter {
130112 }
131113 }
132114
115+ #[ derive( Debug , Error ) ]
116+ pub enum PathFormatterError {
117+ #[ error( "Only relative paths for 'file' and 'output' when 'directory' is relative." ) ]
118+ OnlyRelativePaths ,
119+ #[ error( "Getting current directory failed: {0}" ) ]
120+ CurrentWorkingDirectory ( #[ from] io:: Error ) ,
121+ }
122+
133123 impl TryFrom < & config:: PathFormat > for PathFormatter {
134- type Error = ConfigurationError ;
124+ type Error = PathFormatterError ;
135125
136126 fn try_from ( config : & config:: PathFormat ) -> Result < Self , Self :: Error > {
137127 use config:: PathResolver :: Relative ;
@@ -140,7 +130,7 @@ mod formatter {
140130 if config. directory == Relative
141131 && ( config. file != Relative || config. output != Relative )
142132 {
143- return Err ( ConfigurationError :: OnlyRelativePaths ) ;
133+ return Err ( PathFormatterError :: OnlyRelativePaths ) ;
144134 }
145135 Ok ( Self :: DoFormat ( config. clone ( ) , env:: current_dir ( ) ?) )
146136 }
@@ -512,7 +502,7 @@ mod formatter {
512502 assert ! ( result. is_err( ) ) ;
513503 assert ! ( matches!(
514504 result. err( ) . unwrap( ) ,
515- ConfigurationError :: OnlyRelativePaths
505+ PathFormatterError :: OnlyRelativePaths
516506 ) ) ;
517507 }
518508 }
@@ -640,8 +630,30 @@ mod filter {
640630 }
641631 }
642632
633+ #[ derive( Debug , Error ) ]
634+ pub enum SemanticFilterError {
635+ #[ error( "'Never' or 'Conditional' can't be used after 'Always' for path {0:?}" ) ]
636+ AfterAlways ( path:: PathBuf ) ,
637+ #[ error( "'Never' can't be used after 'Conditional' for path {0:?}" ) ]
638+ AfterConditional ( path:: PathBuf ) ,
639+ #[ error( "'Always' or 'Conditional' can't be used after 'Never' for path {0:?}" ) ]
640+ AfterNever ( path:: PathBuf ) ,
641+ #[ error( "'Always' can't be used multiple times for path {0:?}" ) ]
642+ MultipleAlways ( path:: PathBuf ) ,
643+ #[ error( "'Conditional' can't be used multiple times for path {0:?}" ) ]
644+ MultipleConditional ( path:: PathBuf ) ,
645+ #[ error( "'Never' can't be used multiple times for path {0:?}" ) ]
646+ MultipleNever ( path:: PathBuf ) ,
647+ #[ error( "'Always' can't be used with arguments for path {0:?}" ) ]
648+ AlwaysWithArguments ( path:: PathBuf ) ,
649+ #[ error( "'Conditional' can't be used without arguments for path {0:?}" ) ]
650+ ConditionalWithoutMatch ( path:: PathBuf ) ,
651+ #[ error( "'Never' can't be used with arguments for path {0:?}" ) ]
652+ NeverWithArguments ( path:: PathBuf ) ,
653+ }
654+
643655 impl TryFrom < & [ config:: Compiler ] > for SemanticFilter {
644- type Error = ConfigurationError ;
656+ type Error = SemanticFilterError ;
645657
646658 /// Validate the configuration of the compiler list.
647659 ///
@@ -669,32 +681,32 @@ mod filter {
669681 match compiler. ignore {
670682 // problems with the order of the configuration
671683 IgnoreOrConsider :: Conditional if has_conditional => {
672- return Err ( ConfigurationError :: MultipleConditional ( path. clone ( ) ) ) ;
684+ return Err ( SemanticFilterError :: MultipleConditional ( path. clone ( ) ) ) ;
673685 }
674686 IgnoreOrConsider :: Always if has_always => {
675- return Err ( ConfigurationError :: MultipleAlways ( path. clone ( ) ) ) ;
687+ return Err ( SemanticFilterError :: MultipleAlways ( path. clone ( ) ) ) ;
676688 }
677689 IgnoreOrConsider :: Never if has_never => {
678- return Err ( ConfigurationError :: MultipleNever ( path. clone ( ) ) ) ;
690+ return Err ( SemanticFilterError :: MultipleNever ( path. clone ( ) ) ) ;
679691 }
680692 IgnoreOrConsider :: Always | IgnoreOrConsider :: Never if has_conditional => {
681- return Err ( ConfigurationError :: AfterConditional ( path. clone ( ) ) ) ;
693+ return Err ( SemanticFilterError :: AfterConditional ( path. clone ( ) ) ) ;
682694 }
683695 IgnoreOrConsider :: Always | IgnoreOrConsider :: Conditional if has_never => {
684- return Err ( ConfigurationError :: AfterNever ( path. clone ( ) ) ) ;
696+ return Err ( SemanticFilterError :: AfterNever ( path. clone ( ) ) ) ;
685697 }
686698 IgnoreOrConsider :: Never | IgnoreOrConsider :: Conditional if has_always => {
687- return Err ( ConfigurationError :: AfterAlways ( path. clone ( ) ) ) ;
699+ return Err ( SemanticFilterError :: AfterAlways ( path. clone ( ) ) ) ;
688700 }
689701 // problems with the arguments
690702 IgnoreOrConsider :: Always if compiler. arguments != Arguments :: default ( ) => {
691- return Err ( ConfigurationError :: AlwaysWithArguments ( path. clone ( ) ) ) ;
703+ return Err ( SemanticFilterError :: AlwaysWithArguments ( path. clone ( ) ) ) ;
692704 }
693705 IgnoreOrConsider :: Conditional if compiler. arguments . match_ . is_empty ( ) => {
694- return Err ( ConfigurationError :: ConditionalWithoutMatch ( path. clone ( ) ) ) ;
706+ return Err ( SemanticFilterError :: ConditionalWithoutMatch ( path. clone ( ) ) ) ;
695707 }
696708 IgnoreOrConsider :: Never if !compiler. arguments . match_ . is_empty ( ) => {
697- return Err ( ConfigurationError :: NeverWithArguments ( path. clone ( ) ) ) ;
709+ return Err ( SemanticFilterError :: NeverWithArguments ( path. clone ( ) ) ) ;
698710 }
699711 // update the flags, no problems found
700712 IgnoreOrConsider :: Conditional => {
0 commit comments