exception-handling

Silverlight+WCF exception: Expecting application/soap+xml, received text/xml

删除回忆录丶 提交于 2019-12-21 03:58:53
问题 I have a Silverlight application in which I would like to call a WCF service. When calling the service I receive the following response from the server: 415 Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8 Has anyone experienced this problem before? Does anyone know which configuration settings I need to adjust? Any information on how to fix this would be appreciated. 回答1: Well, you could try using the

Python Ignore Exception and Go Back to Where I Was

北城余情 提交于 2019-12-21 03:40:34
问题 I know using below code to ignore a certain exception, but how to let the code go back to where it got exception and keep executing? Say if the exception 'Exception' raises in do_something1, how to make the code ignore it and keep finishing do_something1 and process do_something2? My code just go to finally block after process pass in except block. Please advise, thanks. try: do_something1 do_something2 do_something3 do_something4 except Exception: pass finally: clean_up EDIT: Thanks for the

Objects.requireNonNull(T obj) instead of null checks and manually thrown IllegalArgumentException?

徘徊边缘 提交于 2019-12-21 03:38:40
问题 Whenever I had to check if the given parameters to a method are not null, I used to write a null check and throw a IllegalArgumentException if the null check fails: if (user == null) { throw new IllegalArgumentException("User can't be null."); } However, by reading the source code of some Java 8 classes such as ArrayList, I found out that Oracle are using Objects.requireNonNull to check a parameter against a null value, and then, if the test fails, a NullPointerException is thrown. This way,

Exceptions vs. Errors in Matlab

跟風遠走 提交于 2019-12-21 03:38:07
问题 Matlab provides two mechanisms for signaling that something has gone wrong: the error function and the language's exception-handling mechanisms MException + try / catch / throw . It looks like they are largely equivalent: The error function and the MException function have very similar syntax. Errors raised via error() can be caught by a catch , while the error-related tools (like dbstop if error and lasterr ) seem to work with exceptions too. Is there ever a reason to prefer error('Foo:Bar',

Write Exceptions to File

拈花ヽ惹草 提交于 2019-12-21 03:36:28
问题 The java project i have created is to be tested for 1800 cases and the output of each case has to matched with the golden(desired) output. I have created a perl script for this and running it on cygwin. There are a few cases which throw exceptions but they are wrongly considered to be correct. I want to add a try catch block in java code so that if any exception is thrown it is caught and stack trace is printed on the file exception.txt . Pseudo Java code: main() { try { ... //complete code

Handling fatal exceptions in ViewModel/Model

爷,独闯天下 提交于 2019-12-21 03:36:18
问题 I have an application written using the M-V-VM approach. The data access is done in the Model. If a fatal error occurs here (for example, the connection to the data source is lost), and Exception is thrown. This Exception bubbles up to the ViewModel. However, because the original trigger of the data access was a data binding, WPF swallows this exception (it is only logged in the output window when the app is run under the debugger). I'd rather this exception remained unhandled so my

When should I use the finally-block in Java's try-catch-finally

Deadly 提交于 2019-12-21 03:35:13
问题 When should I use code snippet A instead of snippet B (i.e. what are the benefits of using snippet A)?: Snippet A: try { // codeblock A } catch (Exception ex) { // codeblock B } finally { //codeblock C } Snippet B: try { // codeblock A } catch (Exception ex) { // codeblock B } //codeblock C 回答1: Use a finally block if you have code that must execute regardless of whether or not an exception is thrown. Cleaning up scarce resources like database connections are a good example. 回答2: An obvious

Handle JobExecutionException in Quartz.net

試著忘記壹切 提交于 2019-12-21 03:18:24
问题 Probably a stupid question... but here goes anyway... I have set up quartz, and can schedule jobs, and I can confirm that jobs (implementing the IJob interface) are working. Looking at the documentation on the site, (Lesson 3 of the tutorial): The only type of exception that you are allowed to throw from the execute method is JobExecutionException . I would like that when an exception occurs that I haven't explicitly handled, it should throw a JobExecutionException, so that I can log it in

Global Exception Handlers in Java

China☆狼群 提交于 2019-12-21 02:24:10
问题 I am thinking of setting up a global, default Exception handler for my (Android) Mobile application(which uses Java syntax) using Thread.setDefaultUncaughtExceptionHandler(...) call. I am thinking of just displaying an Alert Dialog with appropriate message to the user. Are there any gotchas, caveats and rules that one needs to follow when setting DefaultExceptionHandlers ? Any best practices like making sure that the process is killed, full stack trace is written to logs etc. ? Links to

How to handle WinRT exceptions that result in Exception?

只谈情不闲聊 提交于 2019-12-21 01:59:27
问题 If a Windows runtime type raises a COM error .NET seems to wrap this error often (or always?) just into an Exception instance. The error message includes the COM HRESULT error code. When using the new Cryptographic API with AES-CBC for example a wrong buffer length results in an Exception with the message "The supplied user buffer is not valid for the requested operation. ( Exception from HRESULT: 0x800706F8 )". Well, How are we supposed to handle those exceptions? Should we read the HRESULT