Skip to content

Commit

Permalink
Clearer errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BarnabyShearer committed Feb 28, 2024
1 parent eb5cabc commit 8ecbaf9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"name": "two-stroke",
"packageManager": "[email protected]",
"type": "module",
"version": "1.0.5",
"version": "1.0.6",
"devDependencies": {
"@types/eslint": "^8.56.2",
"@types/node": "^20.11.17",
Expand Down
12 changes: 10 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ export function twoStroke<T extends Env>(title: string, release: string) {
sentry,
});
else {
console.error(body.error, rawBody);
console.error({
message: "Request body schema invalid",
error: body.error,
body: rawBody,
});
return new Response(JSON.stringify(body.error), {
status: 400,
});
Expand All @@ -107,7 +111,11 @@ export function twoStroke<T extends Env>(title: string, release: string) {
}
const output = route.output.safeParse(response.body);
if (!output.success) {
console.error(output.error, response.body);
console.error({
message: "Response body schema invalid",
error: output.error,
body: response.body,
});
}
response.headers = response.headers ?? {};
response.headers["Content-Type"] =
Expand Down
2 changes: 1 addition & 1 deletion src/release.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default "undefined";
export default "undefined";

0 comments on commit 8ecbaf9

Please sign in to comment.