when should i let the application crash?

72 Views Asked by At

i have two questions:

Firstly

when should i let the application crash?

Secondly:

this code from resoCoder. i do NOT understand it!!!!!!!!!!!! how could he crash the app if the todos is not right?!

 T getOrCrash() {
    // id = identity - same as writing (right) => right
    return value.fold((f) => throw UnexpectedValueError(f), id);
  }
Option<ValueFailure<dynamic>> get failureOption {
    return body.failureOrUnit
        .andThen(color.failureOrUnit)
        .andThen(todos.failureOrUnit)
        .andThen(
          todos
              .getOrCrash()      // is this crash is okay?!! why to do so???????!
              .map((todoItem) => todoItem.failureOption)
              .filter((o) => o.isSome())
              .getOrElse(0, (_) => none())
              .fold(() => right(unit), (f) => left(f)),
        )
        .fold((f) => some(f), (_) => none());
  }
0

There are 0 best solutions below