-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added retry logic to http adapter
- Loading branch information
1 parent
6c6326f
commit a73e7ba
Showing
5 changed files
with
233 additions
and
49 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { MeshDevice } from "./../meshDevice.ts"; | ||
|
||
export class HttpError extends Error { | ||
constructor( | ||
public readonly status: number, | ||
public readonly statusText: string, | ||
public readonly log: MeshDevice, | ||
) { | ||
super(`HTTP ${status}: ${statusText}`); | ||
|
||
this.name = "HttpError"; | ||
} | ||
} | ||
|
||
/** | ||
* Type guard for Error instances | ||
* Narrows unknown error to Error type with message | ||
*/ | ||
export function isError(error: unknown): error is Error { | ||
return error instanceof Error; | ||
} | ||
|
||
/** | ||
* Type guard for HTTP errors | ||
* Narrows unknown error to Error type with HTTP-specific message | ||
*/ | ||
export function isHttpError(error: unknown): error is Error { | ||
return isError(error) && error.message.startsWith("HTTP"); | ||
} |