7
голосов
2ответов
11174 просмотров

How to catch exception from CloseHandle()

As of the MSDN spec, CloseHandle throws an Exception if an invalid handle is passed to it when it runs under a debugger. Since I want to have clean code, I've inserted some code to catch it. However, it doesn't work, the exception gets uncaught. #include <windows.h> #include <tchar.h&g...

40
голосов
6ответов
38595 просмотров

Java: Global Exception Handler

Is there a way to make a global exception-handler in Java. I want to use like this: "When an exception is thrown somewhere in the WHOLE program, exit." The handler may not catch exceptions thrown in a try-catch body. Martijn

3
голосов
5ответов
618 просмотров

Unchecked Exceptions thrown in a GUI Application

We know that unchecked exceptions are to use in case of violation of the contract of a method. If the application is running in a console, the exception will appear in the console window, along with its stack trace. This is true even for GUI application (say written in Swing) invoked from a conso...

2
голосов
10ответов
478 просмотров

which is a better practice at exception handling?

if I have a specific exception that I expect when it is going to occur; and to handle it for example I chose to display an error message upon its occurance, which would be better to do, and why? Explanatory code: try { string result = dictionary[key]; } catch (KeyNotFoundException e) { ...

3
голосов
3ответов
17947 просмотров

Where to enable metadata (is enabled in config)?

I have a basic wcf service and when I go to the wcfctestclient to test it, I get an error saying metadata could not be found please add it etc. Unfortunately, the MSDN link in the error popup is broken and my WCF service's app.config has metadata enabled: <serviceBehaviors> <behav...

3
голосов
1ответов
4484 просмотров

Handle exceptions with WPF and MVVM

I am attempting to build an application using WPF and the MVVM pattern. I have my Views being populated from my ViewModel purely through databinding. I want to have a central place to handle all exceptions which occur in my application so I can notify the user and log the error appropriately. ...

0
голосов
1ответов
1032 просмотров

BizTalk - Catch EndPoint Not found Exception

The WCF service to which my send & receive ports are configured, is not available; thus I am getting an EndPoint not found exception. How do I catch this exception in the middle of my orcehstration and flow towards a clean exit from the orchestration? I should be able to capture the detail an...

13
голосов
4ответов
36399 просмотров

How to avoid "Response.Redirect cannot be called in a Page callback"

I'm cleaning up some legacy framework code and a huge amount of it is simply coding by exception. No values are checked to see if they are null, and as a result, copious amounts of exceptions are thrown and caught. I've got most of them cleaned up, however, There are a few error / login / secu...

1
голосов
2ответов
2634 просмотров

Using UncaughtExceptionHandler effectively

I got to know about this Java 1.5 capability recently and I developed a sample code to use this. My objective is to restart the thread when it gets dead due to an uncaught exception. public class ThreadManager { public static void main(String[] args) throws InterruptedException { st...

0
голосов
1ответов
1853 просмотров

spring mvc: detect if an exception has been thrown while loading the context

I have a spring mvc application and we run tests with it using jetty. Sometimes the loading of the context totally fails, because bad xml or because Class Not Found exception or because a bean throws an exception in the constructor, setter or init method. In such a case I would like to to stop ...

1
голосов
6ответов
1081 просмотров

Possible syntax for multi-type catch blocks in C#?

Here are two previous questions regarding this topic: Catch multiple Exceptions at once? More Elegant Exception Handling Than Multiple Catch Blocks? I was working today and thought this might be an appropriate syntax should this feature ever be added to the C# language. Anyone have any opinio...

38
голосов
5ответов
107350 просмотров

Raise an error manually in T-SQL to jump to BEGIN CATCH block

Is it possible to raise an error in a stored procedure manually to stop execution and jump to BEGIN CATCH block? Some analog of throw new Exception() in C#. Here is my stored procedure's body: BEGIN TRY BEGIN TRAN -- do something IF @foobar IS NULL -- here i want to raise an error to roll...

8
голосов
3ответов
2497 просмотров

Will CLR handle both CLS-Complaint and non-CLS complaint exceptions?

Just for my clarification : Can i throw both CLS-Complaint and non-CLS complaint exceptions in .NET Framework ?.I am using C# 3.0. When i catch exception catch(Exception ex) { } Will it catch only CLS-Complaint exceptions?. What is the use of RuntimeWrappedException class (can i have a ...

2
голосов
9ответов
343 просмотров

Catch Block Choices

I am reading C# article.It suggests that At the end of the catch block, you have three choices: • Re-throw the same exception, notifying code higher up in the call stack of the exception. • Throw a different exception, giving richer exception information to code higher up in the call stac...

2
голосов
4ответов
768 просмотров

What errors / exceptions trigger Windows Error Reporting?

When running a Delphi application outside the debugger most exceptions that occur seem to be silently ignored (like an access violation). Sometimes however there appears the Windows error reporting dialog (send or not send, you probably know what I mean). What exactly does this mean? What errors ...

3
голосов
5ответов
289 просмотров

catching exception-general doubts

I am learnig CSharp.I have some doubts in handling exceptions.Kindly guide me to improve my coding knowledge. Suppose i construct a code segment : try { SomeWork(); return success; } catch (someException ex) { throw new ExceptionDetails(ex); ret...

13
голосов
5ответов
33995 просмотров

Getting Cross-thread operation not valid

Possible Duplicate: Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on public void CheckUnusedTabs(string strTabToRemove) { TabPage tp = TaskBarRef.tabControl1.TabPages[strTabToRemove]; tp.Controls.Remove(this); TaskBar...

0
голосов
2ответов
609 просмотров

how to apply "catch-all" exception clause to complex python web-scraping script?

I've got a list of 100 websites in CSV format. All of the sites have the same general format, including a large table with 7 columns. I wrote this script to extract the data from the 7th column of each of the websites and then write this data to file. The script below partially works, however: o...

0
голосов
1ответов
245 просмотров

Sharepoint 2007 Web Part Exception Handling for Missing DLL references

I know that you can wrap problematic code in a try/catch block to prevent an error from taking out your webpart. But what can you do for missing references/dlls? Is there anyway of catching those errors before they blow up your SharePoint page?

10
голосов
7ответов
2675 просмотров

How to mark a method will throw unconditionally?

Is there a way to decorate a method that will do some logging, then throw an exception unconditionally, as such? I have code like this: void foo(out int x) { if( condition() ) { x = bar(); return; } // notice that x is not yet set here, but compiler doesn't complain throw new Exception(...

0
голосов
5ответов
4010 просмотров

java: log exception being thrown

In java, I want to log the exception being thrown from a piece of code: try { doRiskyThing(); } catch(Throwable t) { log.warn("too bad"); throw t; } The problem is that now my method must declare it throws throwable. On the other hand, if I log the exception in a finally block, ho...

0
голосов
1ответов
1349 просмотров

Problem with handling exception when sending data by ajax with jQuery

i got following part of one of functions if(continiueSend) { $.ajax ({ type: "POST", url: "mailer.php", data: "somestestdata", timeout: 5000, success: function(a) ...

10
голосов
9ответов
1832 просмотров

Java - where and how should exceptions be used?

I was reading some things about exception handling in Java, to be able to write better code. OK, I admit, I am guilty; I've used too much try-catch{} blocks, I've used ex.printStackTrace() in the catch, not even using a proper logger (actually the System.out and System.err were redirected to a Pr...

0
голосов
1ответов
816 просмотров

Why does my new PowerPC interrupt handler crash only when caches are on

I'm using a PowerPC 750 and have just started experimenting with the external interrupt. I have an interrupt-driven mini program that works fine provided the data cache is off. If I turn the cache on then the PowerPC crashes on the first access to a memory-mapped peripheral after the external i...

0
голосов
4ответов
690 просмотров

When to log errors in ASPX when using database connections?

When to log errors in ASPX when using database connections? In the following code, the authors of Pro ASP.NET 3.5 in C# 2008 (Third ed), suggest logging an SQL error in the catch block. My questions are: Is this common practice? Is this the best practice? In short, would it be better to close ...

1
голосов
6ответов
1490 просмотров

Log4J - how to log an exception caught in an imported library?

I am a pretty new user of Log4J v. 1.2.15, as a friend of mine convinced me of the advantages over console or other forms of logging. However, as i was doing some tests, i've encountered a test case that got me thinking. Here it is what i did : I've configured the properties, added 2 appenders...

18
голосов
2ответов
4093 просмотров

Rails Exception Notification Plugin - Force send email

I'm using the Rails exception_notification plugin in my app and find it very useful. However, there are occasions when I want to catch an exception and deal with it gracefully but still would like to receive the exception notification email. It only seems to send for uncaught exceptions it seems...

0
голосов
1ответов
1132 просмотров

Catch initialization error in Ruby on Rails

What I want to do: redirect the user to a special error page if the database is down. I'm using an Oracle database with the OCI adapter. It appears that, if the database is unavailable (say, down for backup), that the OCI adapter throws an error before I ever hit a controller (based on the stac...

2
голосов
1ответов
680 просмотров

What can cause Application_Error not to be invoked?

For the last 2 weeks I have a case that I can't figure it out, maybe you guys already passed through the same problem or ear/read about it and can help me. I have an ASP.NET Project that I run on my machine and other machines fine, every time I try to temper the QueryString I get an error that i...

2
голосов
3ответов
4879 просмотров

.NET Remoting Exception not handled Client-Side

I checked the rest of the remoting questions, and this specific case did not seem to be addressed. I have a .NET Remoting server/client set up. On the server side I have an object with a method that can throw an exception, and a client which will try to call that method. Server: public bool My...