-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from VirgilSecurity/v0.3.4
v0.3.4
- Loading branch information
Showing
2 changed files
with
18 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
export class PythiaError extends Error { | ||
constructor(message: string) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
constructor(message: string, name: string = 'PythiaError', DerivedClass: any = PythiaError) { | ||
super(message); | ||
Object.setPrototypeOf(this, new.target.prototype); | ||
this.name = 'PythiaError'; | ||
Object.setPrototypeOf(this, DerivedClass.prototype); | ||
this.name = name; | ||
} | ||
} | ||
|
||
export class PythiaClientError extends Error { | ||
export class PythiaClientError extends PythiaError { | ||
readonly code?: number; | ||
readonly httpStatus?: number; | ||
|
||
constructor(message: string, code?: number, httpStatus?: number) { | ||
super(message); | ||
Object.setPrototypeOf(this, new.target.prototype); | ||
this.name = 'PythiaClientError'; | ||
super(message, 'PythiaClientError', PythiaClientError); | ||
this.code = code; | ||
this.httpStatus = httpStatus; | ||
} | ||
} | ||
|
||
export class ProofVerificationFailedError extends Error { | ||
export class ProofVerificationFailedError extends PythiaError { | ||
constructor() { | ||
super('Transformed password proof verification has failed'); | ||
Object.setPrototypeOf(this, new.target.prototype); | ||
this.name = 'ProofVerificationFailedError'; | ||
super( | ||
'Transformed password proof verification has failed', | ||
'ProofVerificationFailedError', | ||
ProofVerificationFailedError, | ||
); | ||
} | ||
} | ||
|
||
export class UnexpectedBreachProofPasswordVersionError extends Error { | ||
export class UnexpectedBreachProofPasswordVersionError extends PythiaError { | ||
constructor(expectedVersion: number, actualVersion: number) { | ||
super( | ||
`Unexpected Breach-proof password version. Expected ${expectedVersion}, got ${actualVersion}`, | ||
'UnexpectedBreachProofPasswordVersionError', | ||
UnexpectedBreachProofPasswordVersionError, | ||
); | ||
Object.setPrototypeOf(this, new.target.prototype); | ||
this.name = 'UnexpectedBreachProofPasswordVersionError'; | ||
} | ||
} |