Skip to content

Commit

Permalink
Improve push auth err handling (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfisher authored Sep 23, 2024
1 parent 41af5fc commit a9d204d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-authsignal",
"version": "1.0.11",
"version": "1.0.12",
"description": "The official Authsignal React Native library.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
38 changes: 9 additions & 29 deletions src/push.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NativeModules } from 'react-native';
import { LINKING_ERROR } from './error';
import { handleErrorCodes, LINKING_ERROR } from './error';
import type {
AuthsignalResponse,
PushChallenge,
Expand Down Expand Up @@ -58,17 +58,13 @@ export class AuthsignalPush {
console.log(ex);
}

if (ex instanceof Error) {
return { error: ex.message };
}

throw ex;
return handleErrorCodes(ex);
}
}

async addCredential({
token,
}: AddCredentialInput): Promise<AuthsignalResponse<boolean>> {
async addCredential({ token }: AddCredentialInput = {}): Promise<
AuthsignalResponse<boolean>
> {
await this.ensureModuleIsInitialized();

try {
Expand All @@ -80,11 +76,7 @@ export class AuthsignalPush {
console.log(ex);
}

if (ex instanceof Error) {
return { error: ex.message };
}

throw ex;
return handleErrorCodes(ex);
}
}

Expand All @@ -99,11 +91,7 @@ export class AuthsignalPush {
console.log(ex);
}

if (ex instanceof Error) {
return { error: ex.message };
}

throw ex;
return handleErrorCodes(ex);
}
}

Expand All @@ -119,11 +107,7 @@ export class AuthsignalPush {
console.log(ex);
}

if (ex instanceof Error) {
return { error: ex.message };
}

throw ex;
return handleErrorCodes(ex);
}
}

Expand All @@ -147,11 +131,7 @@ export class AuthsignalPush {
console.log(ex);
}

if (ex instanceof Error) {
return { error: ex.message };
}

throw ex;
return handleErrorCodes(ex);
}
}

Expand Down

0 comments on commit a9d204d

Please sign in to comment.