Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: specify the route ID in the error message during development when making a form action request to a route without form actions #13167

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ninety-taxis-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

chore: specify the route ID in the error message during development when making a form action request to a route without form actions
6 changes: 4 additions & 2 deletions packages/kit/src/runtime/server/page/actions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as devalue from 'devalue';
import { DEV } from 'esm-env';
import { json } from '../../../exports/index.js';
import { get_status, normalize_error } from '../../../utils/error.js';
import { is_form_content_type, negotiate } from '../../../utils/http.js';
Expand Down Expand Up @@ -27,8 +28,9 @@ export async function handle_action_json_request(event, options, server) {
const no_actions_error = new SvelteKitError(
405,
'Method Not Allowed',
'POST method not allowed. No actions exist for this page'
`POST method not allowed. No form actions exist for ${DEV ? `the page at ${event.route.id}` : 'this page'}`
);

return action_json(
{
type: 'error',
Expand Down Expand Up @@ -153,7 +155,7 @@ export async function handle_action_request(event, server) {
error: new SvelteKitError(
405,
'Method Not Allowed',
'POST method not allowed. No actions exist for this page'
`POST method not allowed. No form actions exist for ${DEV ? `the page at ${event.route.id}` : 'this page'}`
)
};
}
Expand Down
4 changes: 3 additions & 1 deletion packages/kit/test/apps/basics/test/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ test.describe('Errors', () => {
expect(await res_json.json()).toEqual({
type: 'error',
error: {
message: 'POST method not allowed. No actions exist for this page (405 Method Not Allowed)'
message: process.env.DEV
? 'POST method not allowed. No form actions exist for the page at /errors/missing-actions (405 Method Not Allowed)'
: 'POST method not allowed. No form actions exist for this page (405 Method Not Allowed)'
}
});
});
Expand Down
Loading