Skip to content

Commit

Permalink
error handling optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
openhoat committed Sep 25, 2016
1 parent e87cc23 commit 30f3bec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ const _ = require('lodash');

class OhmError extends Error {
constructor(message, extra) {
super(message);
this.name = this.constructor.name;
if (typeof extra === 'undefined' && typeof message === 'object') {
this.extra = message;
this.message = this.message && this.message !== '' ? this.message : JSON.stringify(this.extra);
} else {
this.message = this.message && this.message !== '' ? this.message : message;
this.extra = extra || this.extra;
extra = message;
message = null;
}
this.message = this.message || '';
super(message);
this.name = this.constructor.name;
this.extra = extra;
}

toString() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hw-redis-ohm",
"version": "0.5.10",
"version": "0.5.11",
"description": "Redis Object Hash Mapping",
"main": "lib/ohm.js",
"scripts": {
Expand Down

0 comments on commit 30f3bec

Please sign in to comment.