standardized API error handling