Skip to content

Commit e8fd176

Browse files
authored
Show Python error in frontend if one occurs (#430)
1 parent 2590fc1 commit e8fd176

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

meow/frontend/src/components/Posts/Content.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,26 @@ const NoPosts = () => (
2525
);
2626

2727
const displayStatus = postObject => {
28+
if (postObject.sent_error) {
29+
try {
30+
const error = postObject.sent_error_text;
31+
let i = error.toLowerCase().indexOf("raise"); // search for "raise", then "error"
32+
if (i === -1) {
33+
i = error.toLowerCase().indexOf("error");
34+
}
35+
36+
const DISPLAYED_ERROR_LENGTH = 150;
37+
if (i >= 0) {
38+
if (i + DISPLAYED_ERROR_LENGTH >= error.length) {
39+
return error.substring(error.length - DISPLAYED_ERROR_LENGTH);
40+
}
41+
return error.substring(i, i + DISPLAYED_ERROR_LENGTH);
42+
}
43+
return error.substring(0, DISPLAYED_ERROR_LENGTH);
44+
} catch {
45+
return "Error";
46+
}
47+
}
2848
if (postObject.sending) {
2949
return "Sending";
3050
}
@@ -37,9 +57,6 @@ const displayStatus = postObject => {
3757
}
3858
return "Copy-Edited";
3959
}
40-
if (postObject.sent_error) {
41-
return "Error";
42-
}
4360
return "Draft";
4461
};
4562

meow/frontend/src/components/Posts/styles.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
}
3737

3838
.ant-table-tbody .section,
39-
.ant-table-tbody .slug,
40-
.ant-table-tbody .status {
39+
.ant-table-tbody .slug {
4140
white-space: nowrap;
4241
}
4342

0 commit comments

Comments
 (0)