diff --git a/examples/express/server.js b/examples/express/server.js index cb1a148..fded7ec 100644 --- a/examples/express/server.js +++ b/examples/express/server.js @@ -137,7 +137,7 @@ async function postTransferSol(req, res) { res.json(payload); } catch (err) { - res.status(400).json({ error: err.message || "An unknown error occurred" }); + res.status(500).json({ error: err.message || "An unknown error occurred" }); } } diff --git a/examples/next-js/src/app/api/actions/chaining-basics/next-action/route.ts b/examples/next-js/src/app/api/actions/chaining-basics/next-action/route.ts index b3f7b51..05ee80c 100644 --- a/examples/next-js/src/app/api/actions/chaining-basics/next-action/route.ts +++ b/examples/next-js/src/app/api/actions/chaining-basics/next-action/route.ts @@ -133,9 +133,13 @@ export const POST = async (req: Request) => { } catch (err) { console.log(err); let actionError: ActionError = { message: "An unknown error occurred" }; - if (typeof err == "string") actionError.message = err; + let status = 500; + if (typeof err == "string") { + actionError.message = err; + status = 400; + } return Response.json(actionError, { - status: 400, + status: status, headers, }); } diff --git a/examples/next-js/src/app/api/actions/chaining-basics/route.ts b/examples/next-js/src/app/api/actions/chaining-basics/route.ts index 2ec45d3..df2f729 100644 --- a/examples/next-js/src/app/api/actions/chaining-basics/route.ts +++ b/examples/next-js/src/app/api/actions/chaining-basics/route.ts @@ -142,9 +142,13 @@ export const POST = async (req: Request) => { } catch (err) { console.log(err); let actionError: ActionError = { message: "An unknown error occurred" }; - if (typeof err == "string") actionError.message = err; + let status = 500; + if (typeof err == "string") { + actionError.message = err; + status = 400; + } return Response.json(actionError, { - status: 400, + status: status, headers, }); } diff --git a/examples/next-js/src/app/api/actions/memo/route.ts b/examples/next-js/src/app/api/actions/memo/route.ts index e142354..1442037 100644 --- a/examples/next-js/src/app/api/actions/memo/route.ts +++ b/examples/next-js/src/app/api/actions/memo/route.ts @@ -90,9 +90,13 @@ export const POST = async (req: Request) => { } catch (err) { console.log(err); let actionError: ActionError = { message: "An unknown error occurred" }; - if (typeof err == "string") actionError.message = err; + let status = 500; + if (typeof err == "string") { + actionError.message = err; + status = 400; + } return Response.json(actionError, { - status: 400, + status: status, headers, }); } diff --git a/examples/next-js/src/app/api/actions/stake/route.ts b/examples/next-js/src/app/api/actions/stake/route.ts index 201929a..dcda570 100644 --- a/examples/next-js/src/app/api/actions/stake/route.ts +++ b/examples/next-js/src/app/api/actions/stake/route.ts @@ -76,9 +76,13 @@ export const GET = async (req: Request) => { } catch (err) { console.log(err); let actionError: ActionError = { message: "An unknown error occurred" }; - if (typeof err == "string") actionError.message = err; + let status = 500; + if (typeof err == "string") { + actionError.message = err; + status = 400; + } return Response.json(actionError, { - status: 400, + status: status, headers, }); } diff --git a/examples/next-js/src/app/api/actions/transfer-sol/route.ts b/examples/next-js/src/app/api/actions/transfer-sol/route.ts index bcbc8c0..41b5d40 100644 --- a/examples/next-js/src/app/api/actions/transfer-sol/route.ts +++ b/examples/next-js/src/app/api/actions/transfer-sol/route.ts @@ -74,9 +74,13 @@ export const GET = async (req: Request) => { } catch (err) { console.log(err); let actionError: ActionError = { message: "An unknown error occurred" }; - if (typeof err == "string") actionError.message = err; + let status = 500; + if (typeof err == "string") { + actionError.message = err; + status = 400; + } return Response.json(actionError, { - status: 400, + status: status, headers, }); } @@ -156,9 +160,13 @@ export const POST = async (req: Request) => { } catch (err) { console.log(err); let actionError: ActionError = { message: "An unknown error occurred" }; - if (typeof err == "string") actionError.message = err; + let status = 500; + if (typeof err == "string") { + actionError.message = err; + status = 400; + } return Response.json(actionError, { - status: 400, + status: status, headers, }); }