Skip to content

Commit 9ce0819

Browse files
authored
fix: throw if global css file is not found in webpack context (NativeScript#5186)
1 parent 2704915 commit 9ce0819

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tns-core-modules/application/application-common.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ export function getCssFileName(): string {
8888
}
8989

9090
export function loadAppCss(): void {
91-
events.notify(<LoadAppCSSEventData>{ eventName: "loadAppCss", object: app, cssFile: getCssFileName() });
91+
try {
92+
events.notify(<LoadAppCSSEventData>{ eventName: "loadAppCss", object: app, cssFile: getCssFileName() });
93+
} catch (e) {
94+
throw new Error(`The file ${getCssFileName()} couldn't be loaded! ` +
95+
`You may need to register it inside ./app/vendor.ts.`);
96+
}
9297
}
9398

9499
export function addCss(cssText: string): void {
@@ -97,4 +102,4 @@ export function addCss(cssText: string): void {
97102

98103
global.__onUncaughtError = function (error: NativeScriptError) {
99104
events.notify(<UnhandledErrorEventData>{ eventName: uncaughtErrorEvent, object: app, android: error, ios: error, error: error });
100-
}
105+
}

0 commit comments

Comments
 (0)