error_or 0.0.8+2 copy "error_or: ^0.0.8+2" to clipboard
error_or: ^0.0.8+2 copied to clipboard

outdated

Return a result ErrorOr with either a value T or an error Object.

example/error_or_example.dart

import 'dart:math';

import 'package:error_or/error_or.dart';

Future<ErrorOr<String>> getValueOrError() async {
  await Future.delayed(Duration(milliseconds: 500));
  if (Random().nextBool() == false) {
    return ErrorOr.error(Exception('Error'));
  }
  return ErrorOr.value('Success');
}

void main() async {
  final errorOr = await getValueOrError();
  if (errorOr.hasError) {
    print(errorOr.error);
    return;
  }
  print(errorOr.value);
}
5
likes
0
pub points
43%
popularity

Publisher

verified publisherapptakk.com

Return a result ErrorOr with either a value T or an error Object.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on error_or