Skip to content

Commit

Permalink
Show Python error in frontend if one occurs (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewyu01 authored Feb 29, 2024
1 parent 2590fc1 commit e8fd176
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
23 changes: 20 additions & 3 deletions meow/frontend/src/components/Posts/Content.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ const NoPosts = () => (
);

const displayStatus = postObject => {
if (postObject.sent_error) {
try {
const error = postObject.sent_error_text;
let i = error.toLowerCase().indexOf("raise"); // search for "raise", then "error"
if (i === -1) {
i = error.toLowerCase().indexOf("error");
}

const DISPLAYED_ERROR_LENGTH = 150;
if (i >= 0) {
if (i + DISPLAYED_ERROR_LENGTH >= error.length) {
return error.substring(error.length - DISPLAYED_ERROR_LENGTH);
}
return error.substring(i, i + DISPLAYED_ERROR_LENGTH);
}
return error.substring(0, DISPLAYED_ERROR_LENGTH);
} catch {
return "Error";
}
}
if (postObject.sending) {
return "Sending";
}
Expand All @@ -37,9 +57,6 @@ const displayStatus = postObject => {
}
return "Copy-Edited";
}
if (postObject.sent_error) {
return "Error";
}
return "Draft";
};

Expand Down
3 changes: 1 addition & 2 deletions meow/frontend/src/components/Posts/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
}

.ant-table-tbody .section,
.ant-table-tbody .slug,
.ant-table-tbody .status {
.ant-table-tbody .slug {
white-space: nowrap;
}

Expand Down

0 comments on commit e8fd176

Please sign in to comment.