@@ -30,6 +30,18 @@ pub enum CheckError {
3030 } ,
3131}
3232
33+ impl From < CheckAllToolsError > for CheckError {
34+ fn from ( source : CheckAllToolsError ) -> Self {
35+ Self :: CheckAllFailed { source }
36+ }
37+ }
38+
39+ impl From < CheckSpecificToolError > for CheckError {
40+ fn from ( source : CheckSpecificToolError ) -> Self {
41+ Self :: CheckSpecificFailed { source }
42+ }
43+ }
44+
3345/// Errors that can occur when checking all tools
3446#[ derive( Debug , Error ) ]
3547pub enum CheckAllToolsError {
@@ -55,6 +67,12 @@ pub enum CheckAllToolsError {
5567 } ,
5668}
5769
70+ impl From < DetectionError > for CheckAllToolsError {
71+ fn from ( source : DetectionError ) -> Self {
72+ Self :: DependencyCheckFailed { source }
73+ }
74+ }
75+
5876/// Errors that can occur when checking a specific tool
5977#[ derive( Debug , Error ) ]
6078pub enum CheckSpecificToolError {
@@ -87,6 +105,18 @@ pub enum CheckSpecificToolError {
87105 } ,
88106}
89107
108+ impl From < ParseToolNameError > for CheckSpecificToolError {
109+ fn from ( source : ParseToolNameError ) -> Self {
110+ Self :: ParseFailed { source }
111+ }
112+ }
113+
114+ impl From < DetectionError > for CheckSpecificToolError {
115+ fn from ( source : DetectionError ) -> Self {
116+ Self :: DetectionFailed { source }
117+ }
118+ }
119+
90120/// Errors that can occur when parsing tool names
91121#[ derive( Debug , Error ) ]
92122pub enum ParseToolNameError {
@@ -113,19 +143,18 @@ pub enum ParseToolNameError {
113143/// - Internal error occurs during dependency checking
114144pub fn handle_check ( manager : & DependencyManager , tool : Option < String > ) -> Result < ( ) , CheckError > {
115145 match tool {
116- Some ( tool_name) => check_specific_tool ( manager, & tool_name)
117- . map_err ( |source| CheckError :: CheckSpecificFailed { source } ) ,
118- None => check_all_tools ( manager) . map_err ( |source| CheckError :: CheckAllFailed { source } ) ,
146+ Some ( tool_name) => check_specific_tool ( manager, & tool_name) ?,
147+ None => check_all_tools ( manager) ?,
119148 }
149+
150+ Ok ( ( ) )
120151}
121152
122153fn check_all_tools ( manager : & DependencyManager ) -> Result < ( ) , CheckAllToolsError > {
123154 info ! ( "Checking all dependencies" ) ;
124155 println ! ( "Checking dependencies...\n " ) ;
125156
126- let results = manager
127- . check_all ( )
128- . map_err ( |source| CheckAllToolsError :: DependencyCheckFailed { source } ) ?;
157+ let results = manager. check_all ( ) ?;
129158
130159 let mut missing_count = 0 ;
131160
@@ -168,14 +197,11 @@ fn check_specific_tool(
168197 info ! ( tool = tool_name, "Checking specific tool" ) ;
169198
170199 // Parse tool name to Dependency enum
171- let dep = parse_tool_name ( tool_name)
172- . map_err ( |source| CheckSpecificToolError :: ParseFailed { source } ) ?;
200+ let dep = parse_tool_name ( tool_name) ?;
173201
174202 let detector = manager. get_detector ( dep) ;
175203
176- let installed = detector
177- . is_installed ( )
178- . map_err ( |source| CheckSpecificToolError :: DetectionFailed { source } ) ?;
204+ let installed = detector. is_installed ( ) ?;
179205
180206 if installed {
181207 info ! ( tool = detector. name( ) , "Tool is installed" ) ;
0 commit comments