Created with <3 with dartpad.dev.
Created
October 5, 2023 15:51
-
-
Save MelvinRB27/233dccf0e90f0388d7904c4c25491c3a to your computer and use it in GitHub Desktop.
try, catch, on y finally
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
void main() async { | |
try { | |
final value = await httpGet("melvin"); | |
print(value); | |
} on Exception catch (err) { | |
print('Hubo un error de Exception: $err'); | |
} catch (err) { | |
print('OOPS! Error: $err'); | |
} finally { | |
print('Se completó el try-catch'); | |
} | |
} | |
Future<String> httpGet(String url) async { | |
await Future.delayed(Duration(seconds: 1)); | |
//return 'Respuesta http'; | |
//throw 'Hubo un error'; | |
throw Exception('Hubo un error'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment