diff --git a/src/account.ts b/src/account.ts index a28e756..912ea24 100644 --- a/src/account.ts +++ b/src/account.ts @@ -72,14 +72,16 @@ export class AccountApi { return false; } - public async register(registerRequest: RegisterRequest): Promise { + public async register( + registerRequest: RegisterRequest, + ): Promise { let ret: AxiosResponse; try { ret = await postApiAuthRegister(registerRequest, { baseURL: this.apiUrl, }); } catch (e) { - return false; + return new Error((e as AxiosError).response?.data as string); } return this.checkSuccessBool(ret); @@ -87,7 +89,7 @@ export class AccountApi { public async verifyEmail( verifyEmailRequest: VerifyEmailRequest, - ): Promise { + ): Promise { let ret: AxiosResponse; try { ret = await postApiAccountVerifyEmail( @@ -95,22 +97,24 @@ export class AccountApi { this.buildOptions(), ); } catch (e) { - return false; + return new Error((e as AxiosError).response?.data as string); } return this.checkSuccessBool(ret); } - public async generateOtp(): Promise { + public async generateOtp(): Promise { let ret: AxiosResponse; try { ret = await getApiAuthOtpGenerate(this.buildOptions()); } catch (e) { - return false; + return new Error((e as AxiosError).response?.data as string); } return this.checkSuccessVal(ret); } - public async verifyOtp(otpVerifyRequest: OTPVerifyRequest): Promise { + public async verifyOtp( + otpVerifyRequest: OTPVerifyRequest, + ): Promise { let ret: AxiosResponse; try { ret = await postApiAccountOtpVerify( @@ -118,14 +122,14 @@ export class AccountApi { this.buildOptions(), ); } catch (e) { - return false; + return new Error((e as AxiosError).response?.data as string); } return this.checkSuccessBool(ret); } public async validateOtp( otpValidateRequest: OTPValidateRequest, - ): Promise { + ): Promise { let ret: AxiosResponse; try { ret = await postApiAccountOtpValidate( @@ -133,26 +137,26 @@ export class AccountApi { this.buildOptions(), ); } catch (e) { - return false; + return new Error((e as AxiosError).response?.data as string); } return this.checkSuccessBool(ret); } public async disableOtp( otpDisableRequest: OTPDisableRequest, - ): Promise { + ): Promise { let ret: AxiosResponse; try { ret = await postApiAuthOtpDisable(otpDisableRequest, this.buildOptions()); } catch (e) { - return false; + return new Error((e as AxiosError).response?.data as string); } return this.checkSuccessBool(ret); } public async requestPasswordReset( passwordResetRequest: PasswordResetRequest, - ): Promise { + ): Promise { let ret: AxiosResponse; try { ret = await postApiAccountPasswordResetRequest( @@ -160,14 +164,14 @@ export class AccountApi { this.buildOptions(), ); } catch (e) { - return false; + return new Error((e as AxiosError).response?.data as string); } return this.checkSuccessBool(ret); } public async confirmPasswordReset( passwordResetVerifyRequest: PasswordResetVerifyRequest, - ): Promise { + ): Promise { let ret: AxiosResponse; try { ret = await postApiAccountPasswordResetConfirm( @@ -175,7 +179,7 @@ export class AccountApi { this.buildOptions(), ); } catch (e) { - return false; + return new Error((e as AxiosError).response?.data as string); } return this.checkSuccessBool(ret); } @@ -208,11 +212,11 @@ export class AccountApi { return this.checkSuccessVal(ret); } - public async logout(): Promise { + public async logout(): Promise { try { await postApiAuthLogout(this.buildOptions()); } catch (e) { - return false; + return new Error((e as AxiosError).response?.data as string); } this._jwtToken = undefined;