How to get caller script error details

Asked by ceyhunganioglu

Hi,

I have a script which contains the functions for other scripts to call. Functions try and except. If an exception occurs I write the scripts name using sys.argv[0] but I need some more details. For example "which line of the caller script was running while the error occurred". Is it possible to get all these details?

Many thanks

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Karl (k-d) said :
#1
Revision history for this message
Karl (k-d) said :
#2

Please read similar questions. The following is adapted from https://answers.launchpad.net/sikuli/+question/194222 Comment #4.

import traceback
def getCurrentLineNumberWithTraceback():
    return traceback.extract_stack(limit = 2)[0][1]

Usage:
print getCurrentLineNumberWithTraceback()

Can you help with this problem?

Provide an answer of your own, or ask ceyhunganioglu for more information if necessary.

To post a message you must log in.