Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Been seeing a lot of this lately in various repos. This is unnecessary because you're simply
- //rethrowing the same error that would have been thrown anyway thus rendering your try/catch block useless:
- try {
- //execute some code..
- } catch(error) {
- throw error;
- }
- //The only reason to catch an error is to either handle that error or log it:
- try {
- //execute some code..
- } catch(error) {
- loggerInstance.error('Some error occurred performing some operation...', error);
- throw error;
- }
- //or handle the error by returning a value that can be used by the caller:
- try {
- //execute some code..
- } catch(error) {
- return someDefaultValue;
- }
Add Comment
Please, Sign In to add comment