Refactor: Introduced custom errors for exception handling.