# gfs-auto-trycatch

> the base util to auto add try-catch wrap for Function or ClassMethod

Latest version **1.0.2** (published 2017-06-13) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install gfs-auto-trycatch
pnpm add gfs-auto-trycatch
yarn add gfs-auto-trycatch
bun add gfs-auto-trycatch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-06-13 |
| First published | 2017-04-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Genffy Lee |
| Maintainers | future_team |

## Links

- npm: https://www.npmjs.com/package/gfs-auto-trycatch
- Repository: https://github.com/future-team/gfs-auto-trycatch-base
- Homepage: https://github.com/future-team/gfs-auto-trycatch-base#readme
- Issues: https://github.com/future-team/gfs-auto-trycatch-base/issues
- npm.io page: https://npm.io/package/gfs-auto-trycatch

## Dependencies (4)

- [babel-core](https://npm.io/package/babel-core.md) ^6.24.1
- [babel-types](https://npm.io/package/babel-types.md) ^6.24.1
- [object-assign](https://npm.io/package/object-assign.md) ^3.0.0
- [babel-helper-function-name](https://npm.io/package/babel-helper-function-name.md) ^6.24.1

## Recent versions

- 1.0.2 (latest) — 2017-06-13
- 1.0.1 — 2017-06-13
- 1.0.0 — 2017-04-18

## README

# 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
```bash
$ npm install gfs-auto-trycatch --save-dev
```

```javascript
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;
    }
  }
}*/
```

---
_Source: https://npm.io/package/gfs-auto-trycatch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
