Skip to content

Commit dd52771

Browse files
authored
fix: improve error handling (#5)
* fix: improve error handling * fix: improve error handling * CI: add .github/release.yml * fix
1 parent 92448a4 commit dd52771

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.github/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- 'Type: Meta'
5+
- 'Type: Question'
6+
- 'Type: Release'
7+
8+
categories:
9+
- title: Security Fixes
10+
labels: ['Type: Security']
11+
- title: Breaking Changes
12+
labels: ['Type: Breaking Change']
13+
- title: Features
14+
labels: ['Type: Feature']
15+
- title: Bug Fixes
16+
labels: ['Type: Bug']
17+
- title: Documentation
18+
labels: ['Type: Documentation']
19+
- title: Refactoring
20+
labels: ['Type: Refactoring']
21+
- title: Testing
22+
labels: ['Type: Testing']
23+
- title: Maintenance
24+
labels: ['Type: Maintenance']
25+
- title: CI
26+
labels: ['Type: CI']
27+
- title: Dependency Updates
28+
labels: ['Type: Dependencies', "dependencies"]
29+
- title: Other Changes
30+
labels: ['*']

src/express-lazy-router.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ export function createLazyRouter(options: createLazyLoaderOptions = {}) {
3232
let loadedRouter: express.Router;
3333
const resolveResolver = () => {
3434
return resolver().then((router) => {
35+
if (!router) {
36+
throw new Error(`lazyLoad(resolver) the resolver function should return a promise object, but it returns falsy value: ${router}
37+
38+
You need to return a promise object from the callback function.
39+
40+
lazyLoad(() => import('./path_to_router')),
41+
`);
42+
}
3543
if ("default" in router) {
3644
loadedRouter = router.default;
3745
} else {

0 commit comments

Comments
 (0)