Skip to content

Commit

Permalink
feat: redact internal stack trace when reporting config errors (#11292)
Browse files Browse the repository at this point in the history
* feat: redact internal stack trace when reporting config errors

* lint

---------

Co-authored-by: Rich Harris <[email protected]>
  • Loading branch information
Rich-Harris and Rich-Harris authored Dec 13, 2023
1 parent 04fecb7 commit c17b4c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/smart-crabs-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': minor
---

feat: redact internal stack trace when reporting config errors
10 changes: 9 additions & 1 deletion packages/kit/src/core/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ export async function load_config({ cwd = process.cwd() } = {}) {

const config = await import(`${url.pathToFileURL(config_file).href}?ts=${Date.now()}`);

return process_config(config.default, { cwd });
try {
return process_config(config.default, { cwd });
} catch (e) {
const error = /** @type {Error} */ (e);

// redact the stack trace — it's not helpful to users
error.stack = `Could not load svelte.config.js: ${error.message}\n`;
throw error;
}
}

/**
Expand Down

0 comments on commit c17b4c9

Please sign in to comment.