Option or Exception
Choosing between Option and exception depends on the nature of the error. Use Option when absence is a normal, expected result; use exceptions when the situation is a genuine error that the caller must handle.
Lookup operations typically return Option because "not found" is a normal business scenario, and the caller might substitute a default value or ignore it. The findScore on the right returns ?Int64, allowing the caller to gracefully handle non-existent usernames.
Conversely, illegal arguments, insufficient resources, etc. should throw exceptions. The withdraw on the right throws an exception when balance is insufficient or the amount is negative, because these are programming errors or serious problems that should propagate upward.
Option forces the caller to handle the absence case, while exceptions can automatically propagate upward until caught. Choose the appropriate mechanism based on the severity of the error and handling requirements.
InsufficientBalanceException.