httpexceptions
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -5,2 +5,3 @@ /// <reference path="typings/node/node.d.ts" /> | ||
(function (HTTPException_1) { | ||
var debugEnable = true; | ||
HTTPException_1.HTTPException = require('./lib/http-exception'); | ||
@@ -20,2 +21,6 @@ HTTPException_1.BadGateway = require('./lib/types/badgateway'); | ||
HTTPException_1.Unauthorized = require('./lib/types/unauthorized'); | ||
function debug(b) { | ||
debugEnable = b; | ||
} | ||
HTTPException_1.debug = debug; | ||
/** | ||
@@ -49,2 +54,5 @@ * | ||
.send(err.getMessage()); | ||
if (debugEnable) { | ||
throw err; | ||
} | ||
} | ||
@@ -51,0 +59,0 @@ }; |
@@ -16,2 +16,4 @@ /// <reference path="typings/node/node.d.ts" /> | ||
var debugEnable = true; | ||
export var HTTPException = require('./lib/http-exception'); | ||
@@ -32,2 +34,5 @@ export var BadGateway = require('./lib/types/badgateway'); | ||
export function debug(b:boolean){ | ||
debugEnable = b; | ||
} | ||
/** | ||
@@ -70,2 +75,5 @@ * | ||
if(debugEnable){ | ||
throw err; | ||
} | ||
} | ||
@@ -72,0 +80,0 @@ } |
{ | ||
"name": "httpexceptions", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Provide exception for HTTP Rest API", | ||
@@ -25,6 +25,4 @@ "main": "index.js", | ||
"homepage": "https://github.com/romakita/httpexceptions", | ||
"dependencies": { | ||
}, | ||
"devDependencies":{ | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"chai": "^2.1.0", | ||
@@ -31,0 +29,0 @@ "grunt": "~0.4.5", |
@@ -26,10 +26,37 @@ # HTTPExceptions [![Build Status](https://travis-ci.org/Romakita/httpexceptions.svg?branch=master)](https://travis-ci.org/Romakita/httpexceptions) | ||
Install | ||
--- | ||
## Install | ||
Use `npm install http-exceptions`. | ||
Use `npm install httpexceptions`. | ||
Test | ||
--- | ||
## API | ||
``` javascript | ||
var httpException = require('httpexception'); | ||
var express = require('express'); | ||
var app = express(); | ||
httpException.debug(true); | ||
app.use(httpException.mime('application/json')); | ||
//or | ||
app.use(httpException.mime(['application/json', 'text/xml'])); | ||
app.get('/my/route/exception', function(req, res){ | ||
throw new httpException.BadRequest('Custom Message'); //Emit | ||
//or | ||
throw new httpException.HTTPException(510, 'Custom Message'); | ||
}); | ||
//at the end | ||
//GlobalHandler middleware catch exception and send response to the client | ||
app.use(httpException.globalHandler()); | ||
``` | ||
## Test | ||
Use `npm test`. | ||
@@ -36,0 +63,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169624
3745
64