You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BuiltIn: Call Method loses traceback if calling the method fails #4476
if call_method is failing with an error then we are not getting trace back of the failure, we are just getting the failure message and it is hard to debug such failures
Yes, Assume that we have one python module and I have called a method and want to see the at which line of the code the failure appeared?? how to see at which line it is failed
Yeah, there's problem if the exception occurs somewhere else. The reason is that the original traceback is lost because we raise a new RuntimeError if calling the method fails. Python 3 makes it possible to attach context information to the exception like raise NewError from old but it seems that our traceback formatting code needs to be enhanced slightly as well. Fixing this is so easy that I can still include it into RF 5.1.
Notice that the fix won't be backported to RF 4.1 or any other older version. If you need to use older versions and must have a fix, you need to patch your installation yourself. Alternatively, and probably better, you should change your code into a library and call those methods as keywords.
A trivial fix would be just reraising the original exception, but then the error message would change and that could cause backwards compatibility problems. Better enhance the code so that traceback is preserved.
changed the title [-]Call method is not logging the traceback on failure[/-][+]BuiltIn: `Call Method` loses traceback if calling the method fails[/+]on Sep 26, 2022
It would actually be enough to fix only the traceback formatting code to get the original traceback included. The problem there is that if the exception has no normal traceback to show, traceback of the original exception isn't shown either. This was a mistake made when adding support for chained exceptions in general in RF 5.0 (#4039). I decided to add from err to call_method anyway because it makes the resulting error a bit better.
Activity
[-]Call method is not logging the traceback[/-][+]Call method is not logging the traceback on failure[/+]kbogineni commentedon Sep 23, 2022
@pekkaklarck
pekkaklarck commentedon Sep 25, 2022
Could you please clarify the problem?
kbogineni commentedon Sep 26, 2022
if call_method is failing with an error then we are not getting trace back of the failure, we are just getting the failure message and it is hard to debug such failures
pekkaklarck commentedon Sep 26, 2022
Do you mean
BuiltIn.call_methodor something you created? Have you tried running tests with--loglevel debug?kbogineni commentedon Sep 26, 2022
It is with call_method and I tried with
--loglevel debugalso but no usekbogineni commentedon Sep 26, 2022
call_method is raising the exception but logging the traceback as None
pekkaklarck commentedon Sep 26, 2022
It's true that if I have something like
the traceback is just this:
I don't think there could be any traceback to show in this case, though. You don't get anything more if you run same thing directly in Python:
Do you have a concrete example where there should be a traceback but isn't?
kbogineni commentedon Sep 26, 2022
Yes, Assume that we have one python module and I have called a method and want to see the at which line of the code the failure appeared?? how to see at which line it is failed
kbogineni commentedon Sep 26, 2022
If you see the above example the traceback is given(if you execute python directly)
pekkaklarck commentedon Sep 26, 2022
Yeah, there's problem if the exception occurs somewhere else. The reason is that the original traceback is lost because we raise a new
RuntimeErrorif calling the method fails. Python 3 makes it possible to attach context information to the exception likeraise NewError from oldbut it seems that our traceback formatting code needs to be enhanced slightly as well. Fixing this is so easy that I can still include it into RF 5.1.Notice that the fix won't be backported to RF 4.1 or any other older version. If you need to use older versions and must have a fix, you need to patch your installation yourself. Alternatively, and probably better, you should change your code into a library and call those methods as keywords.
pekkaklarck commentedon Sep 26, 2022
A trivial fix would be just reraising the original exception, but then the error message would change and that could cause backwards compatibility problems. Better enhance the code so that traceback is preserved.
[-]Call method is not logging the traceback on failure[/-][+]BuiltIn: `Call Method` loses traceback if calling the method fails[/+]kbogineni commentedon Sep 26, 2022
Thanks. We can fix it in version 5 only in that case. We will upgrade robot version
pekkaklarck commentedon Sep 27, 2022
It would actually be enough to fix only the traceback formatting code to get the original traceback included. The problem there is that if the exception has no normal traceback to show, traceback of the original exception isn't shown either. This was a mistake made when adding support for chained exceptions in general in RF 5.0 (#4039). I decided to add
from errtocall_methodanyway because it makes the resulting error a bit better.kbogineni commentedon Sep 27, 2022
Thanks