Skip to content

Handle NPE within a Failure

Latest
Compare
Choose a tag to compare
@lambdista lambdista released this 27 Jul 16:00

Handle NullPointerException within a Failure where possible. For example if a client passes null to the map method instead of a valid Function then the result will be a Failure and no NPE is thrown. This is because the result of map is of type Try too. However if one passes null to forEach, whose result type is void, the only reasonable solution in this case is to fail with a NullPointerException