首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

Is there a better way to handle HTTP error statuses

2012-09-20 
Is there a better way to handle HTTP error statuses?if ([response respondsToSelector:@selector(stat

Is there a better way to handle HTTP error statuses?

if ([response respondsToSelector:@selector(statusCode)]){    int statusCode = [((NSHTTPURLResponse *)response) statusCode];    if (statusCode >= 400)    {        [connection cancel];  // stop connecting; no more delegate messages        NSDictionary *errorInfo          = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:            NSLocalizedString(@"Server returned status code %d",@""),            statusCode]                                        forKey:NSLocalizedDescriptionKey];        NSError *statusError          = [NSError errorWithDomain:NSHTTPPropertyStatusCodeKey                                code:statusCode                            userInfo:errorInfo];        [self connection:connection didFailWithError:statusError];    }}?

热点排行