gfs-auto-trycatch
the base util to auto add try-catch wrap for Function or ClassMethod
Last updated 2 years ago by future_team .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gfs-auto-trycatch 
SYNC missed versions from official npm registry.

gfs-auto-trycatch-base

Auto add try-catch wrap for function base util.

Options

  • sourceRoot: the code source root path
  • filename: in fact this option is file path
  • filenameRelative: file name
  • sourceMap: code source map file content, default is false
  • errorHandleFuncName : error handler function name, default is GFS_TRY_CATCH_ERROR_HANDLE, NOTE: this function name must be defined global.

Usage

$ npm install gfs-auto-trycatch --save-dev
const autoTryCatch = require('gfs-auto-trycatch');
const codeContent = `
class Demo {
  consturctor(){
    this.name = "demo"
  }
  action(){
    console.log('this name is: ', this.name)
  }
}
`
const newCtn = autoTryCatch(codeContent, {});

console.log(newCtn);
//  after add try catch
/*class Demo {
  consturctor() {
    try {
      this.name = "demo";
    } catch (_e) {
      window.GFS_TRY_CATCH_ERROR_HANDLE && window.GFS_TRY_CATCH_ERROR_HANDLE(_e, "", "consturctor", 3, 2);
      throw _e;
    }
  }
  action() {
    try {
      console.log('this name is: ', this.name);
    } catch (_e2) {
      window.GFS_TRY_CATCH_ERROR_HANDLE && window.GFS_TRY_CATCH_ERROR_HANDLE(_e2, "", "action", 6, 2);
      throw _e2;
    }
  }
}*/

Current Tags

  • 1.0.2                                ...           latest (2 years ago)

3 Versions

  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (4)
Dev Dependencies (0)
None

Copyright 2014 - 2017 © taobao.org |