@netsells/catch-continue
A class to allow you to run segments of code in order, catch errors, and retry or continue from where an error occured.
Last updated 5 months ago by sam.boylett .
ISC · Original npm · Tarball · package.json
$ cnpm install @netsells/catch-continue 
SYNC missed versions from official npm registry.

CatchContinue

A class to allow you to run segments of code in order, catch errors, and retry or continue from where an error occured.

Installation

yarn add @netsells/catch-continue

Usage

import CatchContinue from '@netsells/catch-continue';

async function myFunction() {
    const cc = new CatchContinue();

    cc.add(() => {
        // any thrown error will pause execution
    });

    cc.add(() => {
        return Promise((resolve, reject) => {
            // rejecting the promise will pause execution
        });
    });

    cc.add(async () => {
        await someCode(); // errors thrown or promises rejected will pause execution
    });

    try {
        await cc.run('any', 'arguments'); // Any passed arguments will be passed to the segment functions
    } catch(e) {
        cc.continue(); // will run from the segment after the one which errored

        // OR

        cc.retry(); // will run starting from the failed segment
    }
}

Current Tags

  • 1.0.2                                ...           latest (5 months ago)

3 Versions

  • 1.0.2                                ...           5 months ago
  • 1.0.1                                ...           5 months ago
  • 1.0.0                                ...           6 months ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |