Skip to content

Commit

Permalink
Fix confusing function throw
Browse files Browse the repository at this point in the history
  • Loading branch information
magtastic committed Feb 28, 2024
1 parent 825eafc commit a6ec428
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/view-controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AdaptyError, AdaptyPaywall } from 'react-native-adapty';
import { AdaptyPaywall } from 'react-native-adapty';
import { LogContext, LogScope } from 'react-native-adapty/dist/logger';
import { AdaptyPaywallCoder } from 'react-native-adapty/dist/coders/adapty-paywall';

Expand Down Expand Up @@ -106,7 +106,7 @@ export class ViewController {

if (this.id === null) {
log.failed({ error: 'no _id' });
throw this.errNoViewReference();
throw this.errNoViewReference;
}

const body = new ParamMap();
Expand All @@ -129,7 +129,7 @@ export class ViewController {

if (this.id === null) {
log.failed({ error: 'no id' });
throw this.errNoViewReference();
throw this.errNoViewReference;
}

const body = new ParamMap();
Expand Down Expand Up @@ -170,7 +170,7 @@ export class ViewController {
log.start({ _id: this.id });

if (this.id === null) {
throw this.errNoViewReference();
throw this.errNoViewReference;
}

const finalEventHandlers: Partial<EventHandlers> = {
Expand Down Expand Up @@ -208,8 +208,6 @@ export class ViewController {
return unsubscribe;
}

private errNoViewReference(): AdaptyError {
// TODO: Make a separate error type once AdaptyError is refactored
throw new Error('View reference not found');
}
// TODO: Make a separate error type once AdaptyError is refactored
private errNoViewReference = new Error('View reference not found');
}

0 comments on commit a6ec428

Please sign in to comment.