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 std::fs::File; | |
fn main() { | |
let f = File::open("main.jpg"); // main.jpg doesn't exist | |
match f { | |
Ok(f)=> { | |
println!("file found {:?}",f); | |
}, | |
Err(e)=> { | |
println!("file not found \n{:?}",e); //handled error | |
} |
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
func Sqrt(f float64) (float64, error) { | |
if f < 0 { | |
return 0, errors.New("math: square root of negative number") | |
} | |
// implementation | |
} | |
f, err := Sqrt(-1) | |
if err != nil { | |
fmt.Println(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
try { | |
final remaingAmount = await getRemainingAmount(account: account); | |
displayAccountAmount(remaingAmount); | |
} on SocketException catch (_) { | |
displayNoConnectionError(); | |
} catch (e, s) { | |
logException(exception: e, stackTrace: s); | |
rethrow; | |
} |
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
Future<Money> getRemainingAmount({Account account}) async { | |
final response = await backend.getAcccountInfo(account); | |
return response.remainingAmount; | |
} |
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() { | |
WidgetsFlutterBinding.ensureInitialized(); | |
FlutterError.onError = (FlutterErrorDetails errorDetails) { | |
print("onError Exception: $errorDetails was caught by Flutter framework - redirect to Sentry or Firebase."); | |
}; | |
runZonedGuarded(() { | |
createProviders(); | |
runApp(MyApp()); |
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
import 'dart:async'; | |
void main(List<String> arguments) async { | |
Stream<int> stream; | |
runZonedGuarded(() { | |
stream = getStream(); | |
}, (e, s) { | |
print('PRODUCER ZONE Exception handled: $e, $s'); | |
}); |
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
import 'dart:async'; | |
void main(List<String> arguments) async { | |
startListener(getStream()); | |
} | |
Stream<int> getStream() { | |
final intsController = StreamController<int>.broadcast(); | |
int i = 42; | |
Timer.periodic(Duration(seconds: 1), (timer) { |
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
print('Current zone start in: ${Zone.current.toString()}'); | |
runZonedGuarded(() { | |
print( | |
'Current zone inside runZoned: ${Zone.current.toString()} with name ${Zone.current['ZoneName']}'); | |
Timer.run(() { | |
print('Timer runs.'); | |
throw Exception('[Timer] Bad thing happens!'); | |
}); | |
runZonedGuarded( | |
() { |
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
runZonedGuarded((){ | |
Timer.run(() { | |
print('Timer runs.'); | |
throw Exception('[Timer] Bad thing happens!'); | |
}); | |
print('Everything is fine!'); | |
}, (e,s) { | |
print('Exception handled $e, \n$s'); | |
}); |
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
try { | |
Timer.run(() { | |
print('Timer runs.'); | |
throw Exception('[Timer] Bad thing happens!'); | |
}); | |
print('Everything is fine!'); | |
} on IntegerDivisionByZeroException { | |
print('Cant divide to zero'); | |
} finally { | |
print('Clean-up done'); |
NewerOlder