Hi,
We are writing a JIRA Forge app and are noticing the error messages thrown from the backend are truncated. Is there a way to allow it to send the full message to the front end?
Currently this is what our backend code looks like,
// backend
timeDelete = async ({payload, context}) => {
const response = await api.fetch(
// api details here
);
if(response.status < 200 || response.status > 299) {
console.error(await response.clone().text());
let errorMessage = "Error attempting to delete record";
try {
errorMessage += ":\n"
errorMessage += (await response.json()).errorMessage;
} catch (err){
console.error("Issue retrieving error message from body. " + err.message);
errorMessage += "Issue retrieving error message from body. " + err.message
+ ". Please reach out to support if needed."
}
throw new Error(errorMessage);
}
return await response.json();
}
and this is what the request from the frontend looks like
const deleteRecord = async (workLogId) => {
try {
await invoke("timeDelete", payload); // throws error
await workLogCallout.deleteWorkLog(workLogId);
if (typeof deleteSuccessFunction !== "undefined") {
deleteSuccessFunction();
}
} catch (err) {
console.error(err);
setToastInformation({
heading: "An error occurred",
appearance: "error",
message: err.message
});
}
}
//error shown in console
Issue retrieving error message from body. Unexpected token 'r', "refresh ... (truncated)