Last active
August 15, 2016 18:52
-
-
Save florianschmidt1994/7c0bd172ae765c1c0426cf8e59902c06 to your computer and use it in GitHub Desktop.
REGEX: .then(...).catch(...) to try {yield ...} catch (err) { ... }
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
// Find (Regex):(api\..*)\n(.*\.then.*)\n((.*\n)*?)(.*\}\)\n.*\.catch.*\n)((.*\n)*?)(.*\}\);\n) | |
// Replace with:try { \n yield $1; \n $3 } catch (err) { \n $6 \n }\n | |
// Before: | |
api.rejectSponsoring(teamId, eventId, sponsoringId) | |
.then(() => { | |
window.location.reload(); | |
}) | |
.catch((err) => { | |
console.log(err); | |
displayError('Ablehnen fehlgeschlagen'); | |
toggleLoading(button); | |
}); | |
// After: | |
try { | |
yield api.rejectSponsoring(teamId, eventId, sponsoringId); | |
window.location.reload(); | |
} catch (err) { | |
console.log(err); | |
displayError('Ablehnen fehlgeschlagen!'); | |
toggleLoading(button); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment