Created
July 28, 2012 17:41
-
-
Save fivetanley/3194135 to your computer and use it in GitHub Desktop.
Error Callback with try/catch
This file contains hidden or 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
// Disclaimer: I am probably pretty wrong about this. | |
thing.handle( function( err, data ) { | |
try { | |
if ( err ) throw err | |
// js doesn't support specific errors like this, you can only catch a generic error... | |
} catch( NoNetworkConnection e ) { | |
window.alert( 'check your internet connection' ) | |
} catch( InvalidPassword err ) { | |
window.alert( 'check your password' ) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment