Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This helps reducing the places where problems are communicated via RuntimeException and also reduces cases where nullable objects are returned and not properly handled. The old pattern in Little Goblin is: 1. if(problem){throw new RuntimeException(errorMessage)) 2. catch RuntimeException e, render error message from e.getMessage (this breaks with unexpected exceptions lacking a proper messageId...) The new pattern should be: 1. for each problem: add error to OptionalResult 2. return OptionalResult and handle valid/invalid case from there The old pattern mixes serious exceptions with common user errors (for example, using a too-short password), it often uses expensive Exception objects (with complete StackTraces) and can only ever communicate one problem. You can work around the expensive objects problem by using static exceptions, but it's still ugly.
- Loading branch information