exception

Do singleton exceptions work?

A collegue of mine at work gave a presentation on static factory methods (right out of Effective Java), and then gave an example of its use for obtaining static / singleton exceptions. This set off a red flag for me. Aren't exceptions stateful? Aren't they populated by the JVM for stack trace info? What savings do you really get wi...

Exception clogging up my IDE

I'm scanning for dead links on one of my pages. On one i get many "A first chance exception of type 'System.Net.WebException' occurred in System.dll" Dozens of them. How do i have MSVC# NOT display them? i am catching all of these exceptions since i am testing the link (in fact its called testStatus, request only head and returns a bool ...

In C#, are there any built-in exceptions I shouldn't use?

I was just wondering - are there any Exceptions defined in the .NET Framework that I shouldn't throw in my own code, or that it is bad practice to? Should I write my own? ...

Guard page exceptions in Delphi?

There is a post by Raymond Chen, where he tells how bad IsBadXxxPtr function is by eating guard page exception. I don't quite understand how it is applied to Delphi. Who and how should normally (i.e. without call to IsBadXxxPtr) process this exception? I do know that Delphi inserts a code, which (for example) access a memory for large ...

correct way of using a throw try catch error handling

Hello, I have come accross to this function below and I am wondering wether this is the right way of using the error handling of try/catch. public function execute() { $lbReturn = false; $lsQuery = $this->msLastQuery; try { $lrResource = mysql_query($lsQuery); if(!$lrResource) { throw new MysqlException("Unable to execute...

Static exception instance

Hello, Are static exception instances safe to use? Any good reason to avoid the following? public class ResourceHttpHandler : IHttpHandler { private static HttpException notFoundException = new HttpException( (int)HttpStatusCode.NotFound, "Assembly Not Found"); public boo...

What's the most appropriate exception to throw if a required app/web.config configuration setting is not present?

(Asked by @tomhollander on Twitter) What's the most appropriate exception to throw if a required app/web.config configuration setting is not present? ...

How do I get at the sql statement that caused an SQLException using the Postgres JDBC driver in Java?

Background In my current project - a server product with no GUI front-end, I'm trying to write in better error handling support. Errors currently are outputted to the logs and are typically not read by users. We use PostgreSQL as our database backend and we access it using direct JDBC calls and DAOs via a database pooler. Most database...

How do I interpret this C# stack trace? Error on line zero.

Hi all, I'm getting a "Object reference not set to an instance of an object" error with the following at the top of the stack in the logs (C# ASP.NET application): @Web.UI.UserBrochurePage.Page_Load(Object,EventArgs)+25 Line: 0 @System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr,Object,Object,EventArgs)+0 Line: 0 @System.We...

Get more debug info from AxHost?

Hello I'm trying to deploy an application which uses an library that embeds an ActiveX control with AxHost in C#. When I run the installed app on our test rig I catch and present the following exception: Unexpected exception. This application has failed to start because the application configuration is incorrect. Reinstalling the app...

Beginners problem with Groovy on Grails

Hi! I am a newbie at Groovy and I want to modify one example I've found at the Internet (the blog one). I've defined two classes Post and Comment as follows: class Post { static hasMany = [comments:Comment] String title String teaser String content Date lastUpdated SortedSet comments static constraints = { title(nullable...

Way to abort execution of MySQL scripts (raising error perhaps)?

I need to write setup scripts for MySQL (usually run using 'source [file]' from mysql console) that depend partly on existing data, and there are differences in environments, meaning that sometimes script does fail. A common case is that a 'SET' statement with a select (to locate an id) fails to find anything; console sets value to NULL....

What exceptions should be thrown for invalid or unexpected parameters in .NET?

What types of exceptions should be thrown for invalid or unexpected parameters in .NET? When would I choose one instead of another? Follow-up: Which exception would you use if you have a function expecting an integer corresponding to a month and you passed in '42'? Would this fall into the "out of range" category even though it's not ...

Why is my NullPointerException not being caught in my catch block?

I have a thread in which I catch all errors in a big, all-encompassing catch block. I do this so that I can report any error, not just expected ones, in my application. My Runnable looks like this: public final void run() { try { System.out.println("Do things"); /* [1] */ doUnsafeThings(); } catch (Throw...

access objective-c exception in finally block

Given the following situation: @try { @try { // raises an exception :) [receiver raisingFirstException]; } @finally { // raises another exception :) [otherReceiver raisingFinalException]; } } @catch (id e) { printf("exception: %s\n", [[e stringValue] cString]); } Is there any way to eith...

How do I create a custom Error in JavaScript?

For some reason it looks like constructor delegation doesn't work in the following snippet: function NotImplementedError() { Error.apply(this, arguments); } NotImplementedError.prototype = new Error(); NotImplementedError.prototype.name = 'NotImplementedError'; (function test() { function assert(condition, msg) { if (!condi...

In Java how can I validate a thrown exception with JUnit?

When writing unit tests for a Java API there may be circumstances where you want to perform more detailed validation of an exception. I.e. more than is offered by the @test annotation offered by JUnit. For example, consider an class that should catch an exception from some other Interface, wrap that exception and throw the wrapped excep...

ORA-08177: can't serialize access for this transaction

I have a very simple code using ADO.NET which throws ORA-08177 exception. I am not sure what's wrong with this. I am trying this on a windows vista machine which has oracle 32 bit client installed. My compile option for visual studio is set to x86 platform. Dim connection As OracleConnection = Nothing Dim transaction As OracleTransactio...

XamlReader.Load(XmlReader) "Stack Empty" XamlParseException

I'm trying to load a xaml file at runtime. My code looks like this: StringReader stringReader = new StringReader(xamlString); XmlReader xmlReader = XmlReader.Create(stringReader); content = XamlReader.Load(xmlReader); It's basically copy paste of of msdn. the XamlReader.Load line throws a XamlParseE...

C#: Best practice for validating "this" argument in extension methods

Let's say I have an extension method public static T TakeRandom<T>(this IEnumerable<T> e) { ... To validate the argument e, should I: A) if (e == null) throw new NullReferenceException() B) if (e == null) throw new ArgumentNullException("e") C) Not check e What's the consensus? My first thought is to always validate arguments, ...