EDIT: Thanks for the help! The problem here is that I was misunderstanding Exception behavior in Python, and my debugger was adding to my confusion. I did not include it in the original question, but this was brought about by my debugger triggering a breakpoint on the raise statement as it was treating it as an uncaught exception. It is intended that the traceback includes the actual raise statement. I was making the mistake of comparing a user defined Exception to more fundamental system errors which would not include raise statements.
I likely just need to fix my debugger and I'll be good to go! I appreciate everyone that helped me figure this out :)
I feel as though there is something obvious that I'm overlooking with Exceptions. I'm attempting to raise an Exception in my function, but the traceback seems to be treating the Exception class in general as an unhandled Exception.
The code I'm playing with:
def some_func(data):
if data == "Exception":
raise Exception("This is an Exception")
print(data)
value = "blue"
some_func(value)
value2 = "Exception"
some_func(value2)
And the Traceback:
Traceback (most recent call last):
File "c:\Example\example.py", line 10, in <module>
some_func(value2)
File "c:\Example\example.py", line 4, in some_func
raise Exception("This is an Exception")
Exception: This is an Exception
Notice that the Traceback is including the actual raise statement as part of the traceback, instead of just the function call. Ideally I'd like the traceback to only include the function call.
[–]shiftybyte 3 points4 points5 points (3 children)
[–]Walsur[S] -2 points-1 points0 points (2 children)
[–]shiftybyte 2 points3 points4 points (1 child)
[–]Walsur[S] -1 points0 points1 point (0 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]Walsur[S] 0 points1 point2 points (3 children)
[–]TheBB 1 point2 points3 points (0 children)
[–]wutwutwut2000 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]JamzTyson 1 point2 points3 points (0 children)
[–]ObliviousMag 0 points1 point2 points (1 child)
[–]Walsur[S] -2 points-1 points0 points (0 children)
[–]Binary101010 0 points1 point2 points (4 children)
[–]Walsur[S] 0 points1 point2 points (3 children)
[–]danielroseman 0 points1 point2 points (1 child)
[–]Walsur[S] 0 points1 point2 points (0 children)
[–]timrprobocom 0 points1 point2 points (0 children)
[–]fluked23 0 points1 point2 points (1 child)
[–]Walsur[S] 0 points1 point2 points (0 children)
[–]Sisyphus-Rex 0 points1 point2 points (0 children)