Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use more graceful error handling

Kabiru Mwenja84820890cfb5
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/restricted-comment.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/restricted-comment.controller.ts
index 7e697d3b47f..b11b91f03b0 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/restricted-comment.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/restricted-comment.controller.ts
@@ -79,20 +79,20 @@ export default class RestrictedCommentController extends Controller {
const sanitizePath = `/work_packages/${this.workPackagesActivitiesTabIndexOutlet.workPackageIdValue}/activities/sanitize_restricted_mentions`;
const csrfToken = (document.querySelector('meta[name="csrf-token"]') as HTMLMetaElement).content;
- const response = await fetch(sanitizePath, {
- method: 'POST',
- body: JSON.stringify({ journal: { notes: editorData } }),
- headers: {
- 'X-CSRF-Token': csrfToken,
- 'Content-Type': 'application/json',
- },
- });
-
- if (response.ok) {
+ try {
+ const response = await fetch(sanitizePath, {
+ method: 'POST',
+ body: JSON.stringify({ journal: { notes: editorData } }),
+ headers: {
+ 'X-CSRF-Token': csrfToken,
+ 'Content-Type': 'application/json',
+ },
+ });
+
const sanitizedNotes = await response.text();
this.ckEditorInstance.setData(sanitizedNotes);
- } else {
- console.error('Failed to sanitize restricted mentions');
+ } catch (error) {
+ console.error(`Failed to sanitize restricted mentions: ${error}`);
}
}
}