Handling parsing exceptions in one function