File tree Expand file tree Collapse file tree 1 file changed +23
-11
lines changed Expand file tree Collapse file tree 1 file changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -103,20 +103,32 @@ internal EspTool(
103103 {
104104 if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
105105 {
106- // open/close the port to see if it is available
107- using ( var test = new SerialPort ( serialPort , baudRate ) )
108- {
106+ // open/close the COM port to check if it is available
107+ var test = new SerialPort ( serialPort , baudRate ) ;
109108
110- try
111- {
112- test . Open ( ) ;
113- test . Close ( ) ;
114- }
115- catch
109+ try
110+ {
111+ test . Open ( ) ;
112+ test . Close ( ) ;
113+ }
114+ catch ( Exception ex )
115+ {
116+ if ( Verbosity >= VerbosityLevel . Detailed )
116117 {
117- // presume any exception here is caused by the serial not existing or not possible to open
118- throw new EspToolExecutionException ( ) ;
118+ Console . ForegroundColor = ConsoleColor . DarkRed ;
119+
120+ Console . WriteLine ( "" ) ;
121+ Console . WriteLine ( "******************* EXCEPTION *****************" ) ;
122+ Console . WriteLine ( $ "Exception occurred while trying to open <{ serialPort } >:") ;
123+ Console . WriteLine ( $ "{ ex . Message } ") ;
124+ Console . WriteLine ( "***********************************************" ) ;
125+ Console . WriteLine ( "" ) ;
126+
127+ Console . ForegroundColor = ConsoleColor . White ;
119128 }
129+
130+ // presume any exception here is caused by the serial not existing or not possible to open
131+ throw new EspToolExecutionException ( ) ;
120132 }
121133 }
122134 else
You can’t perform that action at this time.
0 commit comments