Skip to content

Commit

Permalink
Update ModuleNotFoundError.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed May 17, 2024
1 parent d8584b2 commit 17ac6c2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions package/src/ModuleNotFoundError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ function getFrameworkType(): "react-native" | "expo" | "expo-go" {

export class ModuleNotFoundError extends Error {
constructor(cause?: unknown) {
const errorCause =
cause instanceof Error
? cause
: new Error(
`Unknown cause! ${typeof cause === "object" ? JSON.stringify(cause) : cause}`
);

// TurboModule not found, something went wrong!
if (global.__turboModuleProxy == null) {
// TurboModules are not available/new arch is not enabled.
Expand All @@ -47,7 +54,7 @@ export class ModuleNotFoundError extends Error {
"Enable the new architecture in your app to use react-native-worklets-core 2.x.x. (See https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md)"
);
const error = messageWithSuggestions(message, suggestions);
super(error, { cause: cause });
super(error, { cause: errorCause });
return;
}

Expand Down Expand Up @@ -93,6 +100,6 @@ export class ModuleNotFoundError extends Error {
}

const error = messageWithSuggestions(message, suggestions);
super(error, { cause: cause });
super(error, { cause: errorCause });
}
}

0 comments on commit 17ac6c2

Please sign in to comment.