Refactor custom exceptions to separate module.
Factory method for parsing literals with exception handling.