Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kbariotis committed May 8, 2015
1 parent c25c54a commit f431e6d
Showing 1 changed file with 47 additions and 44 deletions.
91 changes: 47 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ app.use(function(err, req, res, next) {
delete err.stack;
}

res.status(err.errorCode || 500).json(err);
res.status(err.statusCode || 500).json(err);

});

Expand All @@ -49,116 +49,119 @@ var server = app.listen(3000, function () {

```javascript

throwjs.customError(slug, message, errorCode, internalErrorCode);
throwjs.customError(slug, message, statusCode, statusCode);

```

Parameters:
* **slug**[optional]: A unique identifier of this error
* **message**[optional]: Detailed message of this error
* **errorCode**[optional]: The HTTP Status number to return
* **internalErrorCode**[optional]: An internal unique code identifier of this error
* **statusCode**[optional]: The HTTP Status number to return
* **errorCode**[optional]: An internal unique code identifier of this error

## Errors

All of the classes below have all parameters set up by default, based on [RFC7231](http://tools.ietf.org/html/rfc7231).
But you can override the `message` and the `internalErrorCode` to fit your for personal needs.
But you can override the `message` and the `errorCode` to fit your for personal needs.

### 502 Bad Gateway
### 400 Bad Request
```javascript
throwjs.badGateway(message, internalErrorCode);
throwjs.badRequest(message, errorCode);
```

### 406 Not Acceptable
### 401 Unauthorized
```javascript
throwjs.notAcceptable(message, internalErrorCode);
throwjs.unauthorized(message, errorCode);
```

### 404 Not Found
### 402 Payment Required
```javascript
throwjs.notFound(message, internalErrorCode);
throwjs.paymentRequired(message, errorCode);
```

### 501 Not Implemented
### 403 Forbidden
```javascript
throwjs.notImplemented(message, internalErrorCode);
throwjs.forbidden(message, errorCode);
```

### 407 Proxy Authentication Required
### 404 Not Found
```javascript
throwjs.proxyAuthenticationRequired(message, internalErrorCode);
throwjs.notFound(message, errorCode);
```

### 402 Payment Required
### 405 Method Not Allowed
```javascript
throwjs.paymentRequired(message, internalErrorCode);
throwjs.methodNotAllowed(message, errorCode);
```

### 408 Request Timeout
### 406 Not Acceptable
```javascript
throwjs.requestTimeout(message, internalErrorCode);
throwjs.notAcceptable(message, errorCode);
```

### 503 Service Unavailable
### 407 Proxy Authentication Required
```javascript
throwjs.serviceUnavailable(message, internalErrorCode);
throwjs.proxyAuthenticationRequired(message, errorCode);
```

### 401 Unauthorized
### 408 Request Timeout
```javascript
throwjs.unauthorized(message, internalErrorCode);
throwjs.requestTimeout(message, errorCode);
```

### 400 Bad Request
### 409 Conflict
```javascript
throwjs.badRequest(message, internalErrorCode);
throwjs.conflict(message, errorCode);
```

### 409 Conflict
### 410 Gone
```javascript
throwjs.conflict(message, internalErrorCode);
throwjs.gone(message, errorCode);
```

### 403 Forbidden
### 422 Unprocessable Entity
```javascript
throwjs.forbidden(message, internalErrorCode);
throwjs.unprocessableEntity(message, errorCode);
```

### 504 Gateway Timeout
### 424 Failed Dependency
```javascript
throwjs.gatewayTimeout(message, internalErrorCode);
throwjs.failedDependency(message, errorCode);
```

### 410 Gone
### 500 Internal Server Error
```javascript
throwjs.gone(message, internalErrorCode);
throwjs.internalServerError(message, errorCode);
```

### 505 HTTP Version Not Supported
### 501 Not Implemented
```javascript
throwjs.httpVersionNotSupported(message, internalErrorCode);
throwjs.notImplemented(message, errorCode);
```

### 405 Method Not Allowed
### 502 Bad Gateway
```javascript
throwjs.methodNotAllowed(message, internalErrorCode);
throwjs.badGateway(message, errorCode);
```

### 500 Internal Server Error
### 503 Service Unavailable
```javascript
throwjs.internalServerError(message, internalErrorCode);
throwjs.serviceUnavailable(message, errorCode);
```
### 422 Unprocessable Entity

### 504 Gateway Timeout
```javascript
throwjs.unprocessableEntity(message, internalErrorCode);
throwjs.gatewayTimeout(message, errorCode);
```
### 424 Failed Dependency

### 505 HTTP Version Not Supported
```javascript
throwjs.failedDependency(message, internalErrorCode);
throwjs.httpVersionNotSupported(message, errorCode);
```

### 511 Network Authentication Required
```javascript
throwjs.networkAuthenticationRequired(message, internalErrorCode);
throwjs.networkAuthenticationRequired(message, errorCode);
```

## TODO
Expand Down

0 comments on commit f431e6d

Please sign in to comment.