Skip to content

Commit

Permalink
Merge pull request #321 from maratth/rewrite
Browse files Browse the repository at this point in the history
Code splitting
  • Loading branch information
mariuz authored Feb 16, 2024
2 parents 44852ea + f688024 commit a1ad887
Show file tree
Hide file tree
Showing 13 changed files with 4,945 additions and 4,804 deletions.
38 changes: 38 additions & 0 deletions lib/callback.js
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
}
Loading

0 comments on commit a1ad887

Please sign in to comment.