exception-handling

ASP.NET CustomErrors not firing when exceptions occur in global.asax or in web.config

I have ASP.NET set up to use the CustomErrors functionality: <customErrors mode="On" defaultRedirect="~/ErrorPages/500.aspx" redirectMode="ResponseRewrite"> <error statusCode="404" redirect="~/ErrorPages/404.aspx" /> <error statusCode="500" redirect="~/ErrorPages/500.aspx" /> </customErrors> Everything works nice, and the rele...

Wrapping logging within an exception object

I currently have this class that another programmer in my team coded: public static class SoapExecuter { private static readonly ILog logger; public static Exception ExecuterException { get; private set; } public static bool IsSoapException { get { if (ExecuterException == null) ...

Java equivalent to .NET System.InvalidOperationException

I am not as familiar with Java's exception packages as with those of .NET. I'm in a situation where, if programming in C#, I would throw a System.InvalidOperationException. Before creating my own java.lang.RuntimeException subclass, I need to know if there is a similar exception type I should throw in Java. The exact scenario is: My ...

PHP: Ignoring errors and notices in a specific class

My site is completely custom, as such I like to know when I have poorly written code. I use set_exception_handler and set_error_handler to use custom classes to log errors to a file. This includes notices and warnings. Within my own code, this is fine as I get very few logs and those that I do get are things I actually want to fix. How...

getting asynchronous socket error 10049 even if i use try..except

when ever i run my program(outside the debugger/ide) i get error asynchronous socket error 10049, am i not supposed to recieve a message dialoge : ''error''? see my code below begin try ClientSocket1.open; except showmessage('error'); end; end; what am i doing wrong? ...

VB6 Exception Handling within the calling procedure

I have two procedures procA and procB. procA is calling procB. An exception occurs within procB. I can handle the exception within procB, but i like to handle it within procA and this is what i did not get to work. I'm not very familiar with VB6 but i think this should be possible because MSDN says: If an error occurs while an error...

How do i get ruby to output an exception inside a thread?

When I spawn a thread with Thread.new{} it looks like any exception that happens in that thread never sees the light of day, and the app just quietly ignores it ...

Throw (or correspondingly) on NULL function argument versus letting it all blow up?

In previous large-scale applications requiring high robustness and long up-times, I've always been for validating a pointer function argument when it was documented as "must never be NULL". I'd then throw an std::invalid_argument exception, or similar, if the argument actually was NULL in C++ and return an error code in C. However, I'm ...

Where should I catch exceptions when making use of '"using" keyword in the code?

Which one is better in structure? class Program { static void Main(string[] args) { try { using (Foo f = new Foo()) { //some commands that potentially produce exceptions. } } catch (Exception ex) { Console.WriteLine(ex.Message...

Watertight exception handling with Elmah in an MVC application.

I am trying in design a watertight exception handling strategy for an MVC application in which we use Elmah for logging unhandled exceptions. I would like some critique on some of my thoughts. All application exceptions should be handled in the controller layer. Any unhandled exception below that layer should be the result of a reque...

Exception to throw when expecting a null value?

If I am expecting a null value and get a defined value (within a getter of a property) and want to throw an exception, what would be the proper way to do this in csharp? Is there anything defined already that makes sense in this situation? ...

Handle exception or throw exception in Java

Like such Java code snippet: public void func() throws XXXException { // throw exception to outer body ------ (2) try { ...... } catch(XXXException ex) { // handle exception ------ (1) } } In this condition, how you decide to choose (1) or (2)? Is there any principles in Java exception handling? ...

Sending an exception from thread to main thread?

Hi I want to pass an exception from current thread(that thread isn't main thread)to main thread. Why?cuz I check my hard lock in another thread(that thread use timer for checking), and when HardLock is not accessible or invalid, I create an exception which is define by myself and then throw that exception. So that exception don't work we...

Java - How to throw RuntimeException

I'm trying to throw an exception in my code like this: throw RuntimeException(msg); But when I build in NetBeans I get this error: C:\....java:50: cannot find symbol symbol : method RuntimeException(java.lang.String) location: class ... throw RuntimeException(msg); 1 error Do I need to import something? Am I misspelling i...

How can I disable "Microsoft Visual C++ Debug Library" exception dialogues?

Hi guys, If I run an executable that throws an exception ( built in debug ), I will receive an error dialog, saying something like "Debug assertion failed" and then some information about the exception. While this happens, the program's execution is suspended, until I choose one of "Abort", "Retry" or "Ignore" options. The thing is, I...

Retrive Query from the Exception thrown

Hi all, I have a log table where i need to insert the query which causes errors in the code. I have a common function "WritetoLog". Catch ex As Exception writetolog(ex) End Try My Question is from the ex how do i take the query which causes error. eg. If the insert command is giving exception i should get like this SQL Que...

throw exception in the try block rather than catch block?

I've inherited code in our project which looks like this. It's a method in a class. protected override bool Load() { DataAccess.SomeEntity record; try { record = _repository.Get(t => t.ID.Equals(ID)); if (record == null) { throw new InvalidOperationException("failed to initialize the ob...

How do I bubble up and Exception to my UI. ASP.net

Hi All, I have an aspx page that, on a button click, creates an instance of a serviceRefernece object. In the code behind for my page I have the call wrapped in a try/catch. try { var client = GetClient(); var request = new ActiveVerificationRequestDC(); var response = client.GetActiveVeri...

traceback.print_exc() python question

I am using the following line of code in IDLE to print out my traceback in an eception: traceback.print_exc() For some reason I get the red text error message, but then it is followed by a blue text of "None". Not sure what that None is about, any ideas? ...

Exception Handling in Powershell 1.0

I am using the following code to upload a file using PowerShell 1.0. How can I tell if the upload completed successfully or if there was an error? I need to delete the file if the upload was successful. What I have tried: 1. the trap clause. Cant seem to get this one to work. 2. Checking the return value of $webclient.UploadFile -- this...