Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d75d12f

Browse files
authored
feat: log errors when loading stories (storybookjs#358)
1 parent 6a76a06 commit d75d12f

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

‎app/react-native/src/preview/loadCsf.ts‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,20 @@ const loadStories = (
6868
});
6969
});
7070
} else {
71-
const exported = (loadable as LoadableFunction)();
72-
if (Array.isArray(exported)) {
73-
const csfExports = exported.filter((obj) => obj.default != null);
74-
currentExports = new Map(csfExports.map((fileExports) => [fileExports, null]));
75-
} else {
76-
logger.warn(
77-
`Loader function passed to 'configure' should return void or an array of module exports that all contain a 'default' export. Received: ${JSON.stringify(
78-
exported
79-
)}`
80-
);
71+
try {
72+
const exported = (loadable as LoadableFunction)();
73+
if (Array.isArray(exported)) {
74+
const csfExports = exported.filter((obj) => obj.default != null);
75+
currentExports = new Map(csfExports.map((fileExports) => [fileExports, null]));
76+
} else {
77+
logger.warn(
78+
`Loader function passed to 'configure' should return void or an array of module exports that all contain a 'default' export. Received: ${JSON.stringify(
79+
exported
80+
)}`
81+
);
82+
}
83+
} catch (error) {
84+
logger.warn(`Unexpected error while loading stories: ${error}`);
8185
}
8286
}
8387
const removed = Array.from(global.previousExports.keys()).filter(

0 commit comments

Comments
 (0)