exception-handling

Catching Exceptions in WPF at the FrameWork Level

烈酒焚心 提交于 2019-12-19 09:46:50
问题 I'm developing a light-weight WPF MVVM framework, and would like to be able to catch unhandled exceptions, and ideally recover from them. Ignoring for the moment all the good arguments for not doing this, I encounter the following situation: If I register a handler for AppDomain.CurrentDomain.UnhandledException within the OnStartup method of the App.xaml.cs, as follows... App.xaml.cs: protected override void OnStartup(StartupEventArgs e) { AppDomain.CurrentDomain.UnhandledException += new

Java dealing with exceptions appropriately

半城伤御伤魂 提交于 2019-12-19 09:17:20
问题 not that familiar with JAVA or exception handling. Looking for some advice on what is acceptable and what is frowned upon. The scenario, i'm building a game of life program, I have conditionals set up to check if a cell will be out of bounds and not try to access that 'cell'. My question is, is it acceptable to use a try catch block instead of 8 conditionals, and just do nothing if the arrayOutOfBounds exception is thrown. ie ignore the cells out of bounds, or is this bad practice? for

Correct way to catch NSInvalidArgumentException when using NSExpression [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 09:09:30
问题 This question already has answers here : Catch an exception for invalid user input in swift (3 answers) Closed 2 years ago . I want to validate user created expressions (like "2+2", "5+7" or more complex). I use NSExpression class to parse and calculate this expressions. This is my Playground code: import UIKit let string = "2+2" var ex:NSExpression? do { ex = NSExpression(format: string) } catch { print("String is not valid expression") } if let result = ex?.expressionValue(with: nil,

Why is swallowing InterruptedException ok for subclasses of Thread?

守給你的承諾、 提交于 2019-12-19 08:53:11
问题 In Brian Goetz's article on how to handle InterruptedException, one paragraph stands out: The one time it's acceptable to swallow an interrupt is when you know the thread is about to exit. This scenario only occurs when the class calling the interruptible method is part of a Thread, not a Runnable. I don't get this. Is the reason something to do with the Runnable possibly being handled by a threadpool whereas the Thread is something you start on your own ? 回答1: Basically. The concern

Using Exceptions throwing in C#. Does it affect a performance?

浪子不回头ぞ 提交于 2019-12-19 08:14:08
问题 Basically, the question is: Do the Exceptions in C# affect the performance a lot? Is it better to avoid Exceptions rethrow? If i generate an exception in my code, does it affect a performance? Sorry for the sillines of the question itself 回答1: Microsoft's Design Guidelines for Developing Class Libraries is a very valuable resource. Here is a relevant article: Exceptions and Performance I would also recommend the Framework Design Guidelines book from Microsoft Press. It has a lot of the

WCF web service call - which exception(s) to catch?

血红的双手。 提交于 2019-12-19 07:49:27
问题 I have a program that calls an external web service, and I want to present the user with a friendly dialog if e.g. the server is down, someone cut the cable etc. Assuming the following code try { client.MyWebService() } catch(? ex) { // display friendly dialog explaining what went wrong } what exception(s) should I put in place of the question mark in the code? It is kind of hard to actually test situations like this when everything is working smoothly and I have no control over the external

WCF web service call - which exception(s) to catch?

人盡茶涼 提交于 2019-12-19 07:49:11
问题 I have a program that calls an external web service, and I want to present the user with a friendly dialog if e.g. the server is down, someone cut the cable etc. Assuming the following code try { client.MyWebService() } catch(? ex) { // display friendly dialog explaining what went wrong } what exception(s) should I put in place of the question mark in the code? It is kind of hard to actually test situations like this when everything is working smoothly and I have no control over the external

Python: Suppressing errors from going to commandline?

别来无恙 提交于 2019-12-19 07:32:13
问题 When I try to execute a python program from command line, it gives the following error. These errors do not cause any problem to my ouput. I dont want it to be displayed in the commandline Traceback (most recent call last): File "test.py", line 88, in <module> p.feed(ht) File "/usr/lib/python2.5/HTMLParser.py", line 108, in feed self.goahead(0) File "/usr/lib/python2.5/HTMLParser.py", line 148, in goahead k = self.parse_starttag(i) File "/usr/lib/python2.5/HTMLParser.py", line 226, in parse

WCF Exception: Text Message Encoding and ISO-8859-1 Encoding [duplicate]

二次信任 提交于 2019-12-19 07:24:55
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Calling a webservice that uses ISO-8859-1 encoding from WCF I am trying to consume an external Web Service (the web service has PHP implementation) using VS 2008, .net 3.5, WCF( Environment : Windows XP and VS 2008). I add Service Reference to Web Service, VS generates WCF Proxy. Binding is basicHttpBinding. I call to method in Web Service, using Proxy, then I started getting a ProtocolException, I received the

MonoTouch: uncaughtExceptionHandler?

为君一笑 提交于 2019-12-19 06:56:57
问题 In MonoTouch, how do I register an uncaught exception handler (or similar function) In Obj-C: void uncaughtExceptionHandler(NSException *exception) { [FlurryAnalytics logError:@"Uncaught" message:@"Crash!" exception:exception]; } - (void)applicationDidFinishLaunching:(UIApplication *)application { NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); [FlurryAnalytics startSession:@" "]; .... } 回答1: You add a try-catch handler around the code that (might) throw NSExceptions: try {