From a6ec428c3999c9c2648a89d53731d55d86a983fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magn=C3=BAs=20=C3=93lafsson?= Date: Wed, 28 Feb 2024 13:38:40 +0000 Subject: [PATCH] Fix confusing function throw --- src/view-controller.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/view-controller.ts b/src/view-controller.ts index 221b674..9cdc941 100644 --- a/src/view-controller.ts +++ b/src/view-controller.ts @@ -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'; @@ -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(); @@ -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(); @@ -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 = { @@ -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'); }