Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix confusing function throw #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}