use try/catch instead of error codes