Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a36da2

Browse files
committed
Set message in info before getting runtime cause, refactor likely causes
1 parent269acea commit1a36da2

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

‎backend/main/test_transcript.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
"variables": []
326326
}
327327
],
328-
"friendly":"<p>A <code>NameError</code> exception indicates that a variable or\nfunction name is not known to Python.\nMost often, this is because there is a spelling mistake.\nHowever, sometimes it is because the name is used\nbefore being defined or given a value.</p>",
328+
"friendly":"<p>A <code>NameError</code> exception indicates that a variable or\nfunction name is not known to Python.\nMost often, this is because there is a spelling mistake.\nHowever, sometimes it is because the name is used\nbefore being defined or given a value.</p>\n<p>In your program, the unknown name is <code>sunshine</code>.</p>",
329329
"tail":""
330330
}
331331
]
@@ -2510,7 +2510,7 @@
25102510
]
25112511
}
25122512
],
2513-
"friendly":"<p>A <code>NameError</code> exception indicates that a variable or\nfunction name is not known to Python.\nMost often, this is because there is a spelling mistake.\nHowever, sometimes it is because the name is used\nbefore being defined or given a value.</p>",
2513+
"friendly":"<p>A <code>NameError</code> exception indicates that a variable or\nfunction name is not known to Python.\nMost often, this is because there is a spelling mistake.\nHowever, sometimes it is because the name is used\nbefore being defined or given a value.</p>\n<p>In your program, the unknown name is <code>char</code>.\nThe Python builtin <code>'chr'</code> has a similar name. </p>",
25142514
"tail":""
25152515
}
25162516
]

‎backend/main/workers/tracebacks.py‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,24 @@ def friendly_generic(e):
5050
return""
5151

5252

53-
deffriendly_runtime_cause(e):
54-
info= {}
55-
frame=e.__traceback__.tb_frame
53+
def_friendly_cause(e,setter):
54+
info= {"message":get_message(type(e).__name__,e)}
5655
try:
57-
get_likely_cause(type(e),e,info,frame)
56+
setter(info)
5857
exceptException:
5958
log.exception("Failed to get likely cause of exception")
6059
return""
6160
else:
6261
returninfo.get("cause","")
6362

6463

64+
deffriendly_runtime_cause(e):
65+
frame=e.__traceback__.tb_frame
66+
return_friendly_cause(e,lambdainfo:get_likely_cause(type(e),e,info,frame))
67+
68+
6569
deffriendly_syntax_cause(e):
66-
info= {"message":get_message(type(e).__name__,e)}
67-
try:
68-
analyze_syntax.set_cause_syntax(type(e),e,info)
69-
exceptException:
70-
log.exception("Failed to get likely cause of exception")
71-
return""
72-
else:
73-
returninfo.get("cause","")
70+
return_friendly_cause(e,lambdainfo:analyze_syntax.set_cause_syntax(type(e),e,info))
7471

7572

7673
defprint_friendly_syntax_error(e):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp