Use custom exception instead of just Exception

It makes pattern matching friendly for try-catch statement.