Updated example with custom error type.