readiness-manager
Advanced tools
Comparing version 1.0.1 to 1.1.0
# CHANGELOG | ||
## 1.1.0 (7 December 2020) | ||
- Adding `attempt` over `ActionExecutionError`. | ||
## 1.0.1 (3 December 2020) | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "readiness-manager", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "👨💼 Define when your app is ready", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -80,5 +80,12 @@ | ||
```ts | ||
type ActionErrorHandler = (error: ActionExecutionError, retry: ActionRetry) => void; | ||
interface ActionExecutionError extends Error { | ||
name: string; | ||
stack: string; | ||
attempt: number; | ||
failReason: string; | ||
} | ||
type ActionRetry = () => Promise<void>; | ||
type ActionErrorHandler = (error: ActionExecutionError, retry: ActionRetry) => void; | ||
``` | ||
@@ -125,3 +132,3 @@ | ||
console.log(error); | ||
if (count <= 1) retry(); | ||
if (error.attempt <= 1) retry(); | ||
}); | ||
@@ -128,0 +135,0 @@ |
@@ -16,3 +16,3 @@ /** | ||
class ActionExecutionError extends Error { | ||
constructor(name, error) { | ||
constructor(name, attempt, error) { | ||
super(); | ||
@@ -23,2 +23,3 @@ | ||
name, | ||
attempt, | ||
stack: error.stack, | ||
@@ -25,0 +26,0 @@ failReason: error.message |
@@ -138,8 +138,9 @@ const { | ||
/** | ||
* Tracks a given beacon action | ||
* @param {Beacon} beacon | ||
* Tracks a given beacon action. | ||
* @param {Beacon} beacon - The beacon to execute. | ||
* @param {Number} attempt - The attempt number of current beacon execution. | ||
* @throws {ActionExecutionError} | ||
* @private | ||
*/ | ||
async [Symbols.execute](beacon) { | ||
async [Symbols.execute](beacon, attempt = 1) { | ||
const { name, action } = beacon; | ||
@@ -165,4 +166,4 @@ | ||
this[Symbols.errorHandler]( | ||
new ActionExecutionError(name, error), | ||
() => this[Symbols.execute](beacon) | ||
new ActionExecutionError(name, attempt, error), | ||
() => this[Symbols.execute](beacon, attempt + 1) | ||
); | ||
@@ -169,0 +170,0 @@ } |
@@ -18,2 +18,3 @@ type ReadyCallback = () => void; | ||
stack: string; | ||
attempt: number; | ||
failReason: string; | ||
@@ -20,0 +21,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14925
287
136