I wanted to see the Python Traceback error
def main():
raise Exception("Exception message")
if __name__ == '__main__':
main()
Traceback (most recent call last):
File "c:\path\to\test.py", line 5, in <module>
main()
File "c:\path\to\test.py", line 2, in main
raise Exception("Exception message")
Exception: Exception message
Tasks for python.json(The extension is JSON, but you can write comments)
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "python",
"isShellCommand": true,
"args": [
"${file}"
],
"showOutput": "always",
"problemMatcher": {
"owner": "python",
"fileLocation": "absolute",
"pattern": //[
{
"regexp": "^.*File \"(.*)\", line (\\d+?), in.*$",
"file": 1,
"line": 2
//"loop": true
}
//I really want to get the error message on the last line
//now"problemMatcher"Cannot be handled with the syntax of
// https://code.visualstudio.com/Docs/editor/tasks#_defining-a-multiline-problem-matcher
// https://github.com/Microsoft/vscode/blob/master/src/vs/platform/markers/common/problemMatcher.ts
//{
// "regexp": "^(.*):(.*)$",
// "severity": 1,
// "message": 2
//},
//]
}
}
The output example is as follows.
If you want to stop at the point where the exception was thrown at runtime, you can solve it by just checking "All Exceptions" at the breakpoint at the bottom left of the debug screen. (However, there is one more step because you have to press F5
twice)
Recommended Posts