@betit/orion-node-sdk
Advanced tools
Comparing version 1.0.0-beta.42 to 1.0.0-beta.43
@@ -41,2 +41,10 @@ "use strict"; | ||
/** | ||
* Checks if the object is thenable (a promise). | ||
* | ||
* @param object Anything that can be thenable. | ||
*/ | ||
function isThenable(object) { | ||
return object && typeof object.then === 'function'; | ||
} | ||
/** | ||
* Provides an interface to create your service and register request handlers. | ||
@@ -132,3 +140,3 @@ */ | ||
const promise = handler(req, afterCallback); | ||
if (promise instanceof Promise) { | ||
if (isThenable(promise)) { | ||
promise | ||
@@ -140,3 +148,5 @@ .then(afterCallback) | ||
} | ||
throw err; | ||
else { | ||
throw err; | ||
} | ||
}); | ||
@@ -351,6 +361,13 @@ } | ||
const promise = callback(req, afterCallback); | ||
if (promise instanceof Promise) { | ||
if (isThenable(promise)) { | ||
promise | ||
.then(afterCallback) | ||
.catch((err) => { throw err; }); | ||
.catch((err) => { | ||
if (err instanceof error_1.OrionError) { | ||
afterCallback(new response_1.Response(null, err)); | ||
} | ||
else { | ||
throw err; | ||
} | ||
}); | ||
} | ||
@@ -357,0 +374,0 @@ }); |
{ | ||
"name": "@betit/orion-node-sdk", | ||
"version": "1.0.0-beta.42", | ||
"version": "1.0.0-beta.43", | ||
"description": "SDK for orion", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1748192
3272