Fixed up the api so we can get error codes from any function.