-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #321 from maratth/rewrite
Code splitting
- Loading branch information
Showing
13 changed files
with
4,945 additions
and
4,804 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function doError(obj, callback) { | ||
if (callback) | ||
callback(obj) | ||
} | ||
|
||
function isError(obj) { | ||
return Boolean( | ||
obj != null && typeof obj === "object" && !Array.isArray(obj) && obj.status | ||
); | ||
} | ||
|
||
function doCallback(obj, callback) { | ||
|
||
if (!callback) | ||
return; | ||
|
||
if (obj instanceof Error) { | ||
callback(obj); | ||
return; | ||
} | ||
|
||
if (isError(obj)) { | ||
var error = new Error(obj.message); | ||
var status = obj.status && obj.status.length && obj.status[0] || {}; | ||
error.gdscode = status.gdscode; // main error gds code | ||
error.gdsparams = status.params; // parameters (constraint name, table, etc.) | ||
callback(error); | ||
return; | ||
} | ||
|
||
callback(undefined, obj); | ||
|
||
} | ||
|
||
module.exports = { | ||
doError, | ||
doCallback | ||
} |
Oops, something went wrong.