clean up api exception handling