+ 3

in java we can tell what's the exact error by using catch(Exception e){ e.printStackTrace(); //or System.out.println(e.getMessage()); // or just printing the exception class } is that possible in python in any way ?

10th Sep 2016, 2:47 PM
Hossam Mahmoud
Hossam Mahmoud - avatar
5 Answers
+ 4
It doesnt work with finally out the loop try-except?
10th Sep 2016, 3:09 PM
Carlos Sacanell
Carlos Sacanell - avatar
+ 2
You have the reserved words try, except and raise to use them in the same way you do with catch in Java. Look for examples in the lessons of the app dedicated to exceptions.
10th Sep 2016, 2:53 PM
Carlos Sacanell
Carlos Sacanell - avatar
+ 2
it worked with finally .. it prints the error at the bottom .. but that's okay as long as the rest of the code still running :D thanx a lot @Carlos Sacanell
10th Sep 2016, 3:18 PM
Hossam Mahmoud
Hossam Mahmoud - avatar
+ 2
You are welcome mate! 😀
10th Sep 2016, 3:39 PM
Carlos Sacanell
Carlos Sacanell - avatar
+ 1
yeah I know about try,except and raise .. but I need to print an explanation of what's going on when I use the general "except" without a specific type .. I need to print the type of the error without using "raise" inside except block and making my code stop executing @Carlos Sacanell
10th Sep 2016, 3:04 PM
Hossam Mahmoud
Hossam Mahmoud - avatar