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

Commitbfb0b64

Browse files
committed
Show explanation with friendly-traceback
1 parent3bd8f84 commitbfb0b64

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

‎backend/main/workers/tracebacks.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
importpygments
77
fromcheap_reprimportcheap_repr
8+
fromfriendly_traceback.coreimportget_traceback_info
9+
frommarkdownimportmarkdown
810
frompygments.formatters.htmlimportHtmlFormatter
911
fromstack_dataimport (
1012
style_with_executing_node,
@@ -34,6 +36,13 @@ def didyoumean_suggestions(e) -> List[str]:
3436
]
3537

3638

39+
deffriendly_traceback_info(e):
40+
info=get_traceback_info(type(e),e,e.__traceback__)
41+
generic=info["generic"]
42+
case=info.get("cause","").replace("\n","\n\n")
43+
returnmarkdown(generic+"\n\n"+case)
44+
45+
3746
classTracebackSerializer:
3847
defformat_exception(self,e)->List[dict]:
3948
ife.__cause__isnotNone:
@@ -54,6 +63,7 @@ def format_exception(self, e) -> List[dict]:
5463
),
5564
tail="",
5665
didyoumean=didyoumean_suggestions(e),
66+
friendly=friendly_traceback_info(e),
5767
)
5868
)
5969
returnresult

‎frontend/src/css/main.scss‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@
6565
}
6666
}
6767

68-
.terminalpcode {
69-
color:white;
70-
}
71-
7268
.book-text {
7369
margin-bottom:3em;
7470
}

‎frontend/src/shell/TerminalMessage.jsx‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import React, {Component} from 'react'
22
importAnsiUpfrom"ansi_up";
33

44
importsourceStylesfrom'./defs/styles/TerminalMessage'
5+
import{FontAwesomeIcon}from"@fortawesome/react-fontawesome";
6+
import{faInfoCircle}from"@fortawesome/free-solid-svg-icons";
7+
importPopupfrom"reactjs-popup";
58

69
constansi_up=newAnsiUp();
710

@@ -48,8 +51,28 @@ const Tracebacks = ({tracebacks}) =>
4851
<RepeatedFramesdata={frame.data}/>
4952
)
5053
}
51-
<divclassName="traceback-exception">
52-
<strong>{traceback.exception.type}:</strong>{traceback.exception.message}
54+
<div>
55+
<spanclassName="traceback-exception">
56+
<strong>{traceback.exception.type}:</strong>{traceback.exception.message}
57+
</span>
58+
{" "}
59+
<Popup
60+
trigger={
61+
<spanclassName="friendly-traceback-info">
62+
<FontAwesomeIconicon={faInfoCircle}/>
63+
</span>
64+
}
65+
position="top right"
66+
on={['hover','focus']}
67+
arrow={false}
68+
contentStyle={{
69+
width:"30em",
70+
border:"10px solid grey"
71+
}}
72+
>
73+
<divclassName="markdown-body friendly-traceback-popup"
74+
dangerouslySetInnerHTML={{__html:traceback.friendly}}/>
75+
</Popup>
5376
</div>
5477
{
5578
traceback.didyoumean.length>0&&

‎poetry.lock‎

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dryenv = "^0.0.1"
3131
stack_data ="^0.0.7"
3232
jsonfield ="^3.1.0"
3333
BetterErrorMessages ="^0.4"
34+
friendly-traceback ="^0.1.1"
3435

3536
[tool.poetry.extras]
3637
production = ["gevent","gunicorn","psycopg2"]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp