exception-handling

Why does LINQ query throw an exception when I attempt to get a count of a type

public readonly IEnumerable<string> PeriodToSelect = new string[] { "MONTH" }; var dataCollection = from p in somedata from h in p.somemoredate where h.Year > (DateTime.Now.Year - 2) where PeriodToSelect.Contains(h.TimePeriod) select new { p.Currency, h.Year.Month, h.Value ...

Run time error handling on lazy loaded javascript?

Does anyone have any ideas how to do error handling on lazy loaded javascript? I am using an approach in which an ajax request is called and the code is eval'd in global scope. When a runtime error is struck, it spits out the filename as my lazy loading script and the line number is the error line plus the line number of my eval in my ...

When and how to catch exceptions

I am working on a code-base with a bunch of developers who aren't primarily Computer Science or Software Engineering (Mostly Computer Engineering) I am looking for a good article about when exceptions should be caught and when one should try to recover from them. I found an article a while ago that I thought explained things well, but ...

FaultException.Detail coming back empty

I am trying to catch a given FaultException on a WCF client. I basically need to extract a inner description from the fault class so that I can then package it in another exception for the upper layers to do whatever. I've done this successfully a number of time, what makes it different this time is that fault is declared as an array, ...

Java Exception handling mechanism

Hi, In Java,If I didn't catch the thrown Exception then the Thread execution stops there else if I catch the same then the Thread execution continues after the catch block.Why Java Exception handling designed in this way. Thx ...

Try-catch exception handling practice for iPhone/Objective-C

Hi all, Apologies if this question has already been answered somewhere else, but I could not find any decisive answer when searching on it: I'm wondering when try-catch blocks are to be used in objective-c iPhone applications. Apple's "Introduction to the Objective-C Programming Language" state that exceptions are resource intensive an...

Reporting Max Request Length Exceeded in an ASP.NET MVC view

I am using a custom HTTPModule to check the size of the request being posted. If it is larger than a given size I would like to stop the request but still render the view with an appropriate error message. I want to make it nice and simple to reuse so in my action perhaps having a ValidationAttribute on the model? Has anyone done this ...

try ... catch not working

int main (int argc, const char * argv[]) { <br> NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int a1,b1,c1; @try { NSLog(@"Enter numerator: "); scanf("%i",&a1); NSLog(@"Enter denomenator: "); scanf("%i",&b1); c1 = a1/b1; NSLog(@"%i",c1); } @catch (NSException * e) { NSLog([e name]); ...

Javascript Source Missing

In java script I am including a source file like usual <script src="http://source.com?file=1" type="text/javascript"></script> The problem is that sometimes the file is not accessible and it throws an exception. Is there any way to include a file like this but if its not available catch the exception and navigate to a new page? I don...

Best practices for dealing with LINQ statements that result in empty sequences and the like?

...I'm a little confused, or unsure about how to deal with errors that arise from LINQ statements. I just love being able to pull one or more items from a collection, based on some criteria... with a single line of code. That's pretty awesome. But where I'm torn is with the error handling, or the boundary condition checking. If I wan...

Best way to suppress exceptions raised when third-party service is unavailable?

I've written a Django application which interacts with a third-party API (Disqus, although this detail is unimportant) via a Python wrapper. When the service is unavailable, the Python wrapper raises an exception. The best way for the application to handle such exceptions is to suppress them so that the rest of the page's content can st...

Asynctask Error Handling

I am using AsyncTask to perform some background calculations but I am unable to find a correct way to handle exceptions. Currently I am using the following code: private class MyTask extends AsyncTask<String, Void, String> { private int e = 0; @Override protected String doInBackground(String... params) { try ...

How do I test this method's expected behavior in Java: it spawn a thread, and throws an exception under certain conditions

Suppose that I have a method which spawns a new thread and do some work. Under certain conditions, the newly spawn thread would throw a certain type of exception, which terminates the entire process. I would like to write JUnit tests to verify this behavior. Is there a way to do it? The method is: private void foo() { new Thread() { ...

Top-level exception handling for (visual) web parts

I've looked into this quite extensively and I've found the following: You can do some clever stuff to catch most errors by implementing a base class, see Andreas Knudsen's solution for this. The Error event in UserControl never gets fired, see details here: http://weblogs.asp.net/vga/archive/2003/06/16/8748.aspx What I can't find is ...

Better language feature than exception handling in C++?

(not sure if it's only a C++ thing) Exception handling is hard to learn in C++ and is certainly not a perfect solution but in most cases (other than some specific embedded software contexts) it's certainly the better solution we currently have for exception handling. What about the future? Are there other known ways to handle errors ...

How do I correctly handle system exceptions?

I'm trouble with the exception handling. Specifically, I create a System.Diagnostic.Process object from the process identifier (PID), then I use it to execute my algorithm. I've noticed that this class throw InvalidOperation and ArgumentException exception when accessing to different properties, because the process has already exited whi...

Print the full traceback in python (without halting the program)

I'm writing a program that parses a 10 websites, locates data files, saves the files, and then parses them to make data that can be readily used in numpy. There are TONS of errors this file encounters through bad links, poorly formed xml, missing entries, and other things I've yet to categorize. I initially made this program to handle er...

How scoping is handled in exceptions

How is the scoping of variables handled during exceptions? I suppose this will be language specific, and answers for any specific language are greatly appreciated. At least maybe the big ones? C++, python, Java. This is what I mean: python try: for k, v in map.iteritems(): cnf.conf.set( section, k, ...

How to make an "Exception" type class consumed by jaxb-xjc Throwable?

Is there a way to make a class generated by jaxb-xjc Throwable? I haven't found a way to do it in the binding file. If a schema defines an "Exception" type is there some other way to use it as such? Google results seem to be drowned in other Exceptions and Throwables. ...

Error Handling in Web Design

I'm thinking about some optimal methods for gracefully handling errors on a website. I'm thinking that two modes will dictate how errors are handled: Development Mode Shows all notices, warning, and fatal errors on the view they are generated from Errors are displayed in raw format Production Mode Hide all notices and warnings, no...