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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
function analyzeName () { | |
... | |
}).catch((e)=>{ | |
const reason = new Error(`failed analyzing name. result status ${JSON.stringify(result)}`); | |
reason.stack += `\nCaused By:\n` + e.stack; | |
return reason; | |
}) | |
} |
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
function getName () { | |
return new Promise((resolve)=>{ | |
resolve({status:500}); | |
}); // emulate http call | |
} | |
function getFullName (info) { | |
return new Promise((resolve) => { | |
resolve(info.firstName + ' ' + info.lastName) | |
}) |
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
(node:12977) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'firstName' of undefined | |
(node:12977) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. | |
(node:12977) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 28): TypeError: Cannot read property 'split' of undefined | |
(node:12977) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 29): TypeError: Cannot read property 'split' of undefined | |
... |
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
Error: failed analyzing name. result status {} | |
at getName.then.then.then.then.catch (/Users/guymograbi/dev_env/projects_GIT/posts/improve_stacktrace/index.js:55:24) | |
... | |
Caused By: | |
Error: request to get name has failed | |
at Promise.then (/Users/guymograbi/dev_env/projects_GIT/posts/improve_stacktrace/index.js:6:19) | |
... |
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
Error: failed analyzing name. result status {“name”:{“firstName”:”foo”,”lastName”:”bar”}} | |
at getName.then.then.then.then.catch (/Users/guymograbi/dev_env/projects_GIT/posts/improve_stacktrace/index.js:55:24) | |
... | |
Caused By: | |
Error: fullName is missing | |
at countLetters (/Users/guymograbi/dev_env/projects_GIT/posts/improve_stacktrace/index.js:32:15) | |
... |
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
analyzeName().then((result) => { | |
console.log(result); | |
}).catch((e)=>{ | |
console.log('failed to analyze name',e); | |
}); |
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
/** | |
* | |
* @description | |
* adds an <code>absoluteUrl</code> function on request | |
* | |
* <pre> | |
* var absoluteUrl = req.absoluteUrl('/myRelativeUrl'); //==> http://my.domain/myRelativeUrl | |
* </pre> | |
* | |
* and variable <code>origin</code> on request which will be equals to <code>http://my.domain</code> |
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
const https = require('https'); | |
function doCall (opts = {}, callback) { | |
console.log(`doCall with opts ${JSON.stringify(opts, {}, 2)}`); | |
const data = { | |
'target': { | |
'selector': { | |
'type': 'branches', | |
'pattern': opts.pipeline_name |
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
# get current branch in git repo | |
function parse_git_branch() { | |
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` | |
if [ ! "${BRANCH}" == "" ] | |
then | |
STAT=`parse_git_dirty` | |
echo "[${BRANCH}${STAT}]" | |
else | |
echo "" | |
fi |
OlderNewer