Use custom exception instead of Exception

It makes pattern matching friendly for try-catch statement.