You need to handle {error, badarg} too, and return {error, badarg} if you get it.