Skip to content

Commit

Permalink
fix: show ts error on loadFile (#282)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved error handling for file loading to provide better error
visibility and logging.
- Enhanced error message construction to include more context when file
loading fails.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
fengmk2 authored Jan 2, 2025
1 parent 82ef277 commit 1d3ab39
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export default {
const obj = await importModule(filepath, { importDefaultOnly: true });
return obj;
} catch (e: any) {
if (!e.message && typeof e !== 'string') {
// ts error: test/fixtures/apps/app-ts/app/extend/context.ts(5,17): error TS2339: Property 'url' does not exist on type 'Context'
console.trace(e);
throw e;
}
const err = new Error(`[@eggjs/core] load file: ${filepath}, error: ${e.message}`);
err.cause = e;
debug('[loadFile] handle %s error: %s', filepath, e);
Expand Down

0 comments on commit 1d3ab39

Please sign in to comment.