api exception handling