Skip to content

Commit

Permalink
Merge pull request #5720 from Countly/SER-2097-improve-error-reportin…
Browse files Browse the repository at this point in the history
…g-for-hooks

[SER-2097] improve error reporting for hooks
  • Loading branch information
ArtursKadikis authored Nov 8, 2024
2 parents 426d597 + 81288b3 commit 92a995c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions plugins/hooks/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ plugins.register("/o/hook/list", function(ob) {
});
}
catch (err) {
log.e('get hook list failed');
common.returnMessage(params, 500, "Failed to get hook list");
log.e('get hook list failed', err);
common.returnMessage(params, 500, "Failed to get hook list" + err.message);
}
}, paramsInstance);
return true;
Expand Down Expand Up @@ -551,6 +551,9 @@ plugins.register("/i/hook/status", function(ob) {
data: { updatedHooksCount: Object.keys(statusList).length, requestedBy: params.member._id }
});
common.returnOutput(params, true);
}).catch(function(err) {
log.e('Failed to update hook statuses: ', err);
common.returnMessage(params, 500, "Failed to update hook statuses: " + err.message);
});
}, paramsInstance);
return true;
Expand Down Expand Up @@ -599,8 +602,8 @@ plugins.register("/i/hook/delete", function(ob) {
);
}
catch (err) {
log.e('delete hook failed', hookID);
common.returnMessage(params, 500, "Failed to delete an hook");
log.e('delete hook failed', hookID, err);
common.returnMessage(params, 500, "Failed to delete an hook" + err.message);
}
}, paramsInstance);
return true;
Expand All @@ -627,7 +630,7 @@ plugins.register("/i/hook/test", function(ob) {
const mockData = JSON.parse(params.qstring.mock_data);

if (!(common.validateArgs(hookConfig, CheckHookProperties(hookConfig)))) {
common.returnMessage(params, 403, "hook config invalid");
common.returnMessage(params, 403, "hook config invalid" + JSON.stringify(hookConfig));
return; // Add return to exit early
}

Expand Down Expand Up @@ -692,8 +695,8 @@ plugins.register("/i/hook/test", function(ob) {
return false;
}
catch (e) {
log.e("hook test error", e);
common.returnMessage(params, 503, "Hook test failed.");
log.e("hook test error", e, hookConfig);
common.returnMessage(params, 503, "Hook test failed." + e.message);
return;
}
}, paramsInstance);
Expand Down

0 comments on commit 92a995c

Please sign in to comment.