1- use { serde:: Deserialize , serde_json:: Value } ;
1+ use { serde:: Deserialize , serde_json:: Value , thiserror :: Error } ;
22
33#[ derive( Debug , Deserialize ) ]
44#[ serde( tag = "_tag" ) ]
@@ -14,20 +14,24 @@ pub enum NodeJsResult {
1414 } ,
1515}
1616
17- #[ derive( Debug ) ]
18- pub enum ConfigError {
19- // File operations
20- FileReadFailed ( std:: io:: Error ) ,
21- // JavaScript/TypeScript specific
22- CommandExecutionFailed ( std:: io:: Error ) ,
17+ #[ derive( Debug , Error ) ]
18+ pub enum RcfileError {
19+ #[ error( "Failed to read config file" ) ]
20+ FileReadFailed ( #[ from] std:: io:: Error ) ,
21+ #[ error( "Failed to run Node.js/npx/tsx to retrieve JS/TS config file" ) ]
22+ NodeJsExecutionFailed ( #[ source] std:: io:: Error ) ,
23+ #[ error( "Node.js/npx/tsx process failed with stderr: {stderr}" ) ]
2324 ProcessFailed { stderr : String } ,
24- InvalidUtf8 ( std:: string:: FromUtf8Error ) ,
25- ConfigDeserializationFailed ( serde_json:: Error ) ,
26- ImportAndRequireFailed { import_error : String , require_error : String } ,
27- // JSON specific
28- JsonParseFailed ( serde_json:: Error ) ,
29- // YAML specific
30- YamlParseFailed ( serde_yaml:: Error ) ,
31- // Package.json specific
32- PackageJsonConfigInvalid ( serde_json:: Error ) ,
25+ #[ error( "Config file contains invalid UTF-8" ) ]
26+ InvalidUtf8 ( #[ from] std:: string:: FromUtf8Error ) ,
27+ #[ error( "Config file failed validation" ) ]
28+ InvalidConfig ( #[ from] serde_json:: Error ) ,
29+ #[ error( "Failed to import or require config file: {import_error} {require_error}" ) ]
30+ JavaScriptImportFailed { import_error : String , require_error : String } ,
31+ #[ error( "Failed to parse JSON in config file" ) ]
32+ JsonParseFailed ( #[ source] serde_json:: Error ) ,
33+ #[ error( "Failed to parse YAML in config file" ) ]
34+ YamlParseFailed ( #[ from] serde_yaml:: Error ) ,
35+ #[ error( "Config defined as a property in package.json failed validation" ) ]
36+ PackageJsonConfigInvalid ( #[ source] serde_json:: Error ) ,
3337}
0 commit comments