Skip to content
Snippets Groups Projects
Verified Commit fffd25b6 authored by Mateusz Tyszczak's avatar Mateusz Tyszczak :scroll:
Browse files

Add check for unhandled errors

parent 6f97449e
No related branches found
No related tags found
1 merge request!23Dependencies-related work
Pipeline #107752 passed
......@@ -150,7 +150,8 @@ export class WorkerBee extends EventEmitter implements IWorkerBee {
} // Else -> no new block
} catch (error) {
// Ensure we are emitting the Error instance
super.emit("error", new WorkerBeeError(`Error occurred during automation: ${String(error)}`, error));
if (super.listenerCount("error") > 0)
super.emit("error", new WorkerBeeError(`Error occurred during automation: ${String(error)}`, error));
// Wait before any next operation is performed to reduce spamming the API
await new Promise(res => { setTimeout(res, DEFAULT_BLOCK_INTERVAL_TIMEOUT); });
......
......@@ -149,6 +149,8 @@ export interface IWorkerBeeConstructor {
* Constructs new WorkerBee bot object
*
* @param configuration Configuration for the automation
*
* @note If you do not register an "error" event listener, the error will be dropped silently
*/
new(configuration?: Partial<IStartConfiguration>): IWorkerBee;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment