https://github.com/future-team/gulp-auto-trycatch
gfs-auto-trycatch for gulp
https://github.com/future-team/gulp-auto-trycatch
auto-trycatch gulp
Last synced: 2 months ago
JSON representation
gfs-auto-trycatch for gulp
- Host: GitHub
- URL: https://github.com/future-team/gulp-auto-trycatch
- Owner: future-team
- License: apache-2.0
- Created: 2017-03-14T06:52:59.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-21T05:46:27.000Z (almost 9 years ago)
- Last Synced: 2025-09-13T04:59:35.403Z (10 months ago)
- Topics: auto-trycatch, gulp
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-auto-trycatch
A tool design for auto add `try catch` handler for javascript code when build project.
Developer can hack global error handler to deal errors, such as send it to monitor system.
This repo is `gulp` adpater for `gfs-auto-trycatch`
## Options
`errorHandleFuncName`: how to deal error, the default value is `GFS_TRY_CATCH_ERROR_HANDLE`,
you can use it like this:
```javascript
window.GFS_TRY_CATCH_ERROR_HANDLE = function(ERROR_VARIABLE_NAME, FILENAME, FUNCTION_NAME, LINE, COLUMN){
// do your staff
console.error('get log msg', ERROR_VARIABLE_NAME, FILENAME, FUNCTION_NAME, LINE, COLUMN)
}
```
if you want to use defined it, you need to config `gulpfile.js`:
```javascript
gulp.task('autoTryCatch', function(){
return gulp.src(['./src/**/*.jsx', './src/**/*.es6'])
.pipe(gulpAutoTryCatch({
errorHandleFuncName: "defined_error_handle_name"
}))
.pipe(gulp.dest('./catch'));
});
```
then defined a global function `window.defined_error_handle_name = function(ERROR_VARIABLE_NAME, FILENAME, FUNCTION_NAME, LINE, COLUMN){/**do your staff**/}`
## Usage
```bash
$ npm install gulp-auto-trycatch --save-dev
```
```javascript
const gulp = require('gulp');
const gulpAutoTryCatch = require('gulp-auto-trycatch');
gulp.task('autoTryCatch', function () {
return gulp.src(['./src/**/*.jsx', './src/**/*.es6'])
.pipe(gulpAutoTryCatch())
.pipe(gulp.dest('./catch'));
});
```
## Note
Currently only test in `jsx` and `es6` syntax.