Skip to content

Commit

Permalink
feat: show stack in frontend error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed May 30, 2023
1 parent a03562e commit 28f6d3f
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/endpoint-auth/lib/controllers/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const documentationController = (error, request, response, next) => {
response.render("auth", {
title: response.locals.__("auth.guidance.title"),
error: error.message,
error_details: error.stack,
});
} else if (request.accepts("json")) {
return next(error);
Expand Down
1 change: 1 addition & 0 deletions packages/endpoint-files/lib/controllers/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const deleteController = {
title: response.locals.__("files.delete.title"),
parent: { text: fileName },
error: error.message,
error_details: error.stack,
});
}
},
Expand Down
1 change: 1 addition & 0 deletions packages/endpoint-files/lib/controllers/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const formController = {
response.render("file-form", {
title: response.locals.__("files.upload.title"),
error: error.message,
error_details: error.stack,
});
}
},
Expand Down
1 change: 1 addition & 0 deletions packages/endpoint-posts/lib/controllers/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const deleteController = {
title: response.locals.__(`posts.${action}.title`),
parent: { text: postName },
error: error.message,
error_details: error.stack,
});
}
},
Expand Down
1 change: 1 addition & 0 deletions packages/endpoint-posts/lib/controllers/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const formController = {
postTypeName.toLowerCase()
),
error: error.message,
error_details: error.stack,
});
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test("Returns 500 error creating post", async (t) => {
).textContent;

t.is(response.status, 500);
t.is(result, "Test store: Unauthorized");
t.regex(result, /\bTest store: Unauthorized\b/g);

server.close(t);
});
1 change: 1 addition & 0 deletions packages/endpoint-share/lib/controllers/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const shareController = {
name,
bookmarkOf,
error: error.message,
error_details: error.stack,
minimalui: request.params.path === "bookmarklet",
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/endpoint-share/tests/integration/400-post-share.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ test("Returns 400 error publishing post", async (t) => {
const result = dom.window.document;

t.is(response.status, 400);
t.is(
t.regex(
result.querySelector(".notification--error p").textContent,
"No bearer token provided by request"
/\bNo bearer token provided by request\b/g
);

server.close(t);
Expand Down
2 changes: 2 additions & 0 deletions packages/indiekit/lib/indieauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const IndieAuth = class {
return response.status(401).render("session/login", {
title: response.locals.__("session.login.title"),
error: error.message,
error_details: error.stack,
});
}
};
Expand Down Expand Up @@ -172,6 +173,7 @@ export const IndieAuth = class {
return response.render("session/login", {
title: response.locals.__("session.login.title"),
error: error.message,
error_details: error.stack,
});
}
};
Expand Down

0 comments on commit 28f6d3f

Please sign in to comment.