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...
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 ...
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?
...
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 ...
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...
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...
(Asked by @tomhollander on Twitter)
What's the most appropriate exception to throw if a required app/web.config configuration setting is not present?
...
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...
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...
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...
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...
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 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 ...
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...
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...
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...
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...
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...
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...
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, ...