- 抛出错误的代码
[cpp] view plaincopy- //如果返回的报文是错误信息,则抛出错误
- if([outParams count] <= 0)
- {
- [NSException raise:@"WebService error" format:@"%@", returnJson4SOAP];
- }
- 在调用中捕获错误代码
[cpp] view plaincopy- //从soap 信息中解析出CusotmerDetail 对象
- @try
- {
- customerDetail = [[[SoapRtnJsonParser alloc] init] parse2CustomerDtail:[returnSoapXML dataUsingEncoding:NSUTF8StringEncoding]];
- }@catch (NSException * e) {
- NSLog(@"Exception: %@", e);
- UIAlertView * alert =
- [[UIAlertView alloc]
- initWithTitle:@"错误"
- message: [[NSString alloc] initWithFormat:@"%@",e]
- delegate:self
- cancelButtonTitle:nil
- otherButtonTitles:@"OK", nil];
- [alert show];
- [alert release];
- return;
- }
在ios开发中使用 try 和 catch 来捕获错误。
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:VB下中文URL编码问题的解决
下一篇:vs2005 调试命令摘要举例
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
JS 使用try catch捕获异常
前端是攻克客户的先锋,需要特别注意到用户体验。在开发中,由于各种问题,异常的
前端 代码块 异常处理 监控系统 -
async和await异步捕获机制try/catch
async是 js 有史以来最简单的异步写法,能够用同步的方mise((res,rej) => { if(type){ res(..
异步捕获机制 async/await try/catch javascript 错误处理 -
Java在MVC开发模式中使用try-catch以及throws避免踩坑
场景1.throws是在方法上抛出异常,throw是在语句上抛出异常。2.try-catch是在catc
throws try-catch 静态方法 抛出异常 java -
异常捕获 try catch
加上异常捕获 如果不打印异常信息
异常捕获 异常信息 程序