exception-handling

How can I rethrow an Inner Exception while maintaining the stack trace generated so far?

人走茶凉 提交于 2020-01-11 15:22:31
问题 Duplicate of: In C#, how can I rethrow InnerException without losing stack trace? I have some operations that I invoke asynchronously on a background thread. Sometimes, things go bad. When this happens, I tend to get a TargetInvocationException, which, while appropriate, is quite useless. What I really need is the TargetInvocationException's InnerException, like this: try { ReturnValue = myFunctionCall.Invoke(Target, Parameters); } catch (TargetInvocationException err) { throw err

How can I rethrow an Inner Exception while maintaining the stack trace generated so far?

偶尔善良 提交于 2020-01-11 15:22:03
问题 Duplicate of: In C#, how can I rethrow InnerException without losing stack trace? I have some operations that I invoke asynchronously on a background thread. Sometimes, things go bad. When this happens, I tend to get a TargetInvocationException, which, while appropriate, is quite useless. What I really need is the TargetInvocationException's InnerException, like this: try { ReturnValue = myFunctionCall.Invoke(Target, Parameters); } catch (TargetInvocationException err) { throw err

Want program to continue even when there is an exception

假装没事ソ 提交于 2020-01-11 14:43:50
问题 I have searched a few times but I kinda, didnt found what i exactly wanted. I was working out with exceptional handling (try/catch), where i found this obstacle. If the program finds an exception, it terminated whatsoever. I tried calling a function in the catch part, but it still terminates. void exception_handle() //This is for handling exception if user inputs a char instead of int// { user_play uplay; try { uplay.usersentry(); } catch(std::runtime_error& e) { cout<<"Input a string bro,

trap exceptions comprehensively in Jython

試著忘記壹切 提交于 2020-01-11 11:53:10
问题 This is my attempt so far to trap all exceptions in Jython code. The most difficult thing, I find, is trapping exceptions when you override a method from a Java class: with the "vigil" decorator below (which also tests whether the EDT/Event Despatch Thread status is correct) you can find out the first line where the code is thrown... so you can identify the method itself. But not the line. Furthermore, tracing stack frames back through Python and Java stacks is completely beyond me. Obviously

Automating VideoLan's VLC using Delphi

若如初见. 提交于 2020-01-11 11:03:30
问题 I've generated a type-library import unit from v.2.2.1 of VideoLan's VLC player and embedded the resulting plug-in component in a simple Delphi (D7 and XE8) form. Code extract is below. The basic functionality of the component is fine - I can play a (local) .MP4 file, stop it, speed it up and down, etc without any problem. However, there is one basic function which is not working, namely volume control. The plug-in displays a v. simple (compared with the one in VLC running as an app) toobar

How to continue execution of a try catch statement in java [duplicate]

余生颓废 提交于 2020-01-11 10:22:11
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Java: Try-Catch-Continue? I'm reading in information from a text file and I want my code to throw an exception if there is an invalid type being read. However, I can't figure out how to have my program continue after an exception has been found while(input.hasNext()) { try{ type = input.next(); name = input.next(); year = input.nextInt(); } catch(InputMismatchException ex) { //System.out.println("** Error:

What's the best practice to recover from a FileSystemWatcher error?

一个人想着一个人 提交于 2020-01-11 08:42:06
问题 After a FileSystemWatcher.Error event was raised, I have no clue about what to do next. The exception can be a [relatively] minor one, such as too many changes at once in directory which doesn't affect the watcher's watching process, but it can also be a big issue - such as the watched directory being deleted, in which case the watcher is no longer functional. My question is what is the best way to handle the Error event? 回答1: Depends on the error surely? If it is too much data because the

How do I stop my application from zombifying after I handle an uncaught Excepition?

百般思念 提交于 2020-01-11 05:13:26
问题 I am handling any uncaught exceptions that occur in my application via: Thread.setDefaultUncaughtExceptionHandler(this); were this is my launcher Activity implementing UncaughtExceptionListener. I handle the exception and send it off to my log server just fine, however, my application then doesn't end. It just runs along as a zombie until the home or back button is pressed. How can I kill the process after handling the exception? Edit Here is a test and working activity that throws an

Why doesn't Python exit from a raised exception when executed with an absolute path?

做~自己de王妃 提交于 2020-01-11 04:41:27
问题 SOLVED: Rebooting the machine appears to have removed the issue. I will update if the problem returns. I'm having an issue where Python2.6 hangs after an exception is raised, specifically when foo.py is called with an absolute path ( /home/user/bar/foo.py ). I am then required to ctrl+c out of the program. If called from within the bar directory as ./foo.py or from the root directory as ./home/user/bar/foo.py , the program terminates correctly. foo.py: #!/usr/bin/env python2.6 print 'begin' x

Should I catch exceptions only to log them?

Deadly 提交于 2020-01-10 07:15:12
问题 Should I catch exceptions for logging purposes? public foo(..) { try { ... } catch (Exception ex) { Logger.Error(ex); throw; } } If I have this in place in each of my layers (DataAccess, Business and WebService) it means the exception is logged several times. Does it make sense to do so if my layers are in separate projects and only the public interfaces have try/catch in them? Why? Why not? Is there a different approach I could use? 回答1: Definitely not. You should find the correct place to