exception-handling

How to handle ConcurrentModificationException in Android

為{幸葍}努か 提交于 2019-12-05 06:13:06
Im trying to delete item from a ArrayList. Some times it pops an exception, "java.util.ConcurrentModificationException". First i tried to remove them by array_list_name.remove(i), but it failed and some people were asked to use Iterator instead. So my current code is as follows. for (Iterator<Collectable> iter = array_list_name.iterator(); iter.hasNext();) { Collectable s = iter.next(); if (s.equals(array_list_name.get(id))){ iter.remove(); return true; } } And i call "array_list_name" inside onDraw() function in view. my view is a SurfaceView. Can any one suggest me how to delete items from

Handle ViewExireException/ajax and display a Primefaces dialog

。_饼干妹妹 提交于 2019-12-05 05:35:57
问题 I don't redirect or forward my user to another page. So when the my SessionExpiredExceptionHandler (extends ExceptionHandlerWrapper ) handles the ViewExireException. I want the user to stay on the same page and display a PrimeFaces Dialog. For notifying that the session has expired and that the user needs to login again (dialog based). I am use Servlet 3.1 functions to login/logout user and Basic/file for auth-method to map the users to different system roles. What is happening now is that

terminate called recursively

◇◆丶佛笑我妖孽 提交于 2019-12-05 05:13:52
As far as I know, terminate() is called when there is some problem with exception handling(usually it's just not caught). What I got is just one error line terminate called recursively . After googling for some time I found a lot of examples of terminate called after throwing an instance of ... terminate called recursively But it's not my case. As I don't have this hint about the exception type, I'm wondering what does this terminate called recursively mean by itself. Sorry I can't provide the code, so any guess will be helpful. I'm compiling with g++ 4.5.2 under Ubuntu 11.04. Thanks a lot,

What type of Exception should I throw when an unknown value is passed into a switch statement

岁酱吖の 提交于 2019-12-05 05:11:11
Edit 1 Updated to make the enum not an argument to the method... Question This type of problem comes up a lot with enums in switch statements. In the example code, the developer has accounted for all countries the program is currently using, but if another country is added to the Country enum, an exception should be thrown. My question is, what type of exception should be thrown? Example Code: enum Country { UnitedStates, Mexico, } public string GetCallingCode(Guid countryId){ var country = GetCountry(countryId); switch (country) { case Country.UnitedStates: return "1"; break; case Country

Cancel task.delay without exception or use exception to control flow?

久未见 提交于 2019-12-05 04:56:11
I'm unsure about two possibilities to react to an event in my code. Mostly I'm concerned about which one needs less resources. I have a method with an observer registered to an eventproducer . If the eventproducer returns something, the method exits and the caller of the method starts the method again (you can think of it as a kind of a long polling). The eventproducer sometimes fires lots of events per seconds and sometimes rests for minutes. The first approach was to await a delay of 500ms and then check if there is something to return or otherwise (until a timeout of 5 minutes) again delay

How do you handle an exception with ASP.net MVC's AsyncController?

与世无争的帅哥 提交于 2019-12-05 04:52:05
I've got this... public void FooAsync() { AsyncManager.OutstandingOperations.Increment(); Task.Factory.StartNew(() => { try { doSomething.Start(); } catch (Exception e) { AsyncManager.Parameters["exc"] = e; } finally { AsyncManager.OutstandingOperations.Decrement(); } }); } public ActionResult FooCompleted(Exception exc) { if (exc != null) { throw exc; } return View(); } Is there a better way of passing an exception back to ASP.net? Cheers, Ian. Task will catch the exceptions for you. If you call task.Wait() , it will wrap any caught exceptions in an AggregateException and throw it.

How to Handle Exceptions and Error Messages in Laravel 5?

不羁的心 提交于 2019-12-05 04:48:38
When i get this error: QueryException in Connection.php line 620: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry can i handle it with my own flash error message instead of: Whoops, looks like something went wrong You have two ways to handle exceptions and show a custom response: 1) Let the framework handle them for you: If you don't handle exceptions by yourself, Laravel will handle them in the class: App\Exceptions\Handler In the render method you can intercept the renderning of all the exceptions the framework rises. So, if you want to do something in particular when a

Why should I use exception handling in php?

主宰稳场 提交于 2019-12-05 04:39:57
I've been programming PHP for a long time, but not so much PHP 5... I've known about exception handling in PHP 5 for some time, but never really looked into it. After a quick Google it seems fairly pointless to use exception handling - I can't see the advantages of using it over just using some if() {} statements, and perhaps my own error handling class or whatever. There's got to be a bunch of good reasons for using it (I guess?!) otherwise it wouldn't have been put into the language (probably). Can anyone tell me of some good benefits it has over just using a bunch of if statements or a

Optional printing of stack trace in Java

拥有回忆 提交于 2019-12-05 04:36:36
I am creating a java application in which there is a possibility that exceptions might be thrown. I am handling these exceptions in a try-catch block and printing appropriate messages so that the business users don't have to see the ugly stack trace in case of a failure. But now when I debug, I would like to invoke the JAR file in such a way that it will print the stack traces for me, so that I can know where exactly the problem lies. Can someone enlighten me on how this can be achieved? Why not use Logging levels.? DEBUG for your technical errors and INFO or ERROR with the business codes that

Unhandled exceptions in Google Apps Script

回眸只為那壹抹淺笑 提交于 2019-12-05 04:36:16
I have created a public Web App with access to my private spreadsheet data. I can catch and log exceptions in try..catch , but: is it possible to catch all unhandled exceptions, like browsers window.onerror ? can I view logs of unhandled exceptions somewhere? by exceptions like "Service invoked too many times" my app is even not getting run, so here I definitely can`t handle the exceptions. Is there logs with such kind of exceptions? These are so simple questions, so that I'm bit confused to ask them, but after hours of research I could not find the answers. Thank you in advance. These are