-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor combiner * Remove combiner timeouts * fix lint --------- Co-authored-by: Alec Schaefer <[email protected]>
- Loading branch information
1 parent
619ae9d
commit 66b1fb3
Showing
10 changed files
with
254 additions
and
146 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
packages/phone-number-privacy/combiner/src/common/error.ts
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ErrorType } from '@celo/phone-number-privacy-common' | ||
|
||
export class OdisError extends Error { | ||
constructor(readonly code: ErrorType, readonly parent?: Error, readonly status: number = 500) { | ||
// This is necessary when extending Error Classes | ||
super(code) // 'Error' breaks prototype chain here | ||
Object.setPrototypeOf(this, new.target.prototype) // restore prototype chain | ||
} | ||
} | ||
|
||
export function wrapError<T>( | ||
valueOrError: Promise<T>, | ||
code: ErrorType, | ||
status: number = 500 | ||
): Promise<T> { | ||
return valueOrError.catch((parentErr) => { | ||
throw new OdisError(code, parentErr, status) | ||
}) | ||
} |
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
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
Oops, something went wrong.