exception

The difference between re-throwing parameter-less catch and not doing anything?

Suppose I have the following two classes in two different assemblies: //in assembly A public class TypeA { // Constructor omitted public void MethodA { try { //do something } catch { throw; } } } //in assembly B public class TypeB { public void MethodB { try { TypeA a = ne...

C# thread interruption stopped working

I dont know why but i can no longer interrupt my own thread. thread = new Thread(new ParameterizedThreadStart(this.doWork)); thread.Start(param); ... thread.Interrupt(); //in doWork() try { ... } catch (System.Threading.ThreadInterruptedException) { //it never hits here. it use to } I search and i dont have any catch in my code and t...

LINQ and .COUNT timing out

I have a general question, and curiosity about LINQ and timeouts. I have a live application running and I am receiving timeouts on the following code. The following code, which is normal, and I don't see anything wrong: private static tblUser GetUserLinq(string email, string password) { DataContext db = new DataCon...

SQLite and Javascript : Checking for existence of data before inserting OR letting SQLite throw an exception.

My primary question is which approach is faster. Some briefing I'm developing an application using Mozilla. I have this one module where I capture some data and store it in database. The data comes in intermittently. No duplicates are to be stored. For discussion sake we can assume a table with just one column, and let's name that c...

Forcing English language exceptions in .NET framework

Hi, While working with ASP.NET MVC, I have noticed that exception messages issued by the .NET framework installed on my System are in German. I'd really prefer English messages, so I can post them on SO. I know this has been asked before on SO, but strangely enough none of the suggested workarounds seem to work in my case. I have alre...

Java BrowserLauncher throwing InvocationTargetException

I'm using the BrowserLauncher2 library for opening the user's default web browser from my Swing app, but it's throwing a very confusing exception: public static void openURL(String url) { try{ BrowserLauncher launcher = new BrowserLauncher(); launcher.openURLinBrowser(url); }catch(Exception e){ ...

why does my JScript (windows script host) exit with 0 on an uncaught exception?

I have some JScript which does some stuff with an ODBC connection. An exception was thrown by the ODBC ActiveXObject object and not caught in my script. I expected that the script would exit with an non 0 value but it didn't. Anyone know why this is the case and how to get it to exit with a non 0 value on an uncaught exception? ...

How can I determine if my ActiveRecord object violates a unique database key/index?

ActiveRecord's validates_uniqueness_of is vulnerable to race conditions. To really ensure uniqueness requires additional safeguards. One suggestion from the ActiveRecord RDocs is to create a unique index on the database, for example by including in your migrations: add_index :recipes, :name, :unique => true This will ensure at the d...

WindowsMobile: Application Exits after handling Exception from DialogForm

I have the following simple scenario: A DialogForm with a Button, the Button_click throws an exception. A MainForm with a button and a Label, in the click I show a new instance of the DialogForm inside a Catch block. If I run this setup in regular WinForms, I can catch the Exception as expected. If I run this in WinMobile (I've test...

How to get the method call history?

I am trying to get the list of calls made from the beginning of a try block to the exception. In the code below, when I fall into the Catch block, the StackTrace in the Exception object is the following : at ConsoleApplication.Program.MethodC() / at ConsoleApplication.Program.Main(String[] args). This is totally expected, but doesn't hel...

Find if an SQLException was thrown because of a duplicate

I have a Java program that is agnostic from the database and I need to know, while inserting, if an SQLException was thrown because of a duplicate key. If I was using a single database driver I would simply use the ErrorCode, but since I can be using very different engines the ErrorCode are not the same. Has anyone done this before? An...

How do I throw an Exception from the caller's scope?

I'd like to create a routine that does some logging, takes some other actions, and then throws an Exception. I'd like this routine to be called from many different locations. However, creating Exceptions in this routine means they will have this routine in their stack trace. I would rather the stack trace not report this utility routi...

Why not use exceptions as regular flow of control?

My question boils down to : “Why not use exception (or error- for that matter) handling for regular program flow? To avoid all standard-answers I could have googled on, I will provide an example you all can attack at will. C# and Java (and too many others) have with plenty of types some of ‘overflow’ behaviour I don’t like at all. (t...

Is there a difference between "throw" and "throw ex"?

There are some posts that asks what the difference between those two are already. (why do I have to even mention this...) But my question is different in a way that I am calling "throw ex" in another error god-like handling method. public class Program { public static void Main(string[] args) { try { ...

Try/Catch in Python

When you just want to do a try catch without handling the exception, how do you do it in Python? try : shutil.rmtree ( path ) except : pass ...

How to avoid a NullReferenceException

if (alMethSign[z].ToString().Contains(aClass.Namespace)) Here, I load an exe or dll and check its namespace. In some dlls, there is no namespace, so aclass.namespace is not present and it's throwing a NullReferenceException. I have to just avoid it and it should continue with rest of the code. If I use try-catch, it executes the catc...

Handling NHibernate Exceptions

What's the best practice for handling exceptions in NHibernate? I've got a SubjectRepository with the following: public void Add(Subject subject) { using (ISession session = HibernateUtil.CurrentSession) using (ITransaction transaction = session.BeginTransaction()) { session.Save(subject); ...

NETCFv35.Messages.EN.wm.cab?

In the .NET Compact Framework 3.5 exceptions by default don't have their actual error message string installed. Great for cramming the compact framework into windows mobile devices with less memory, but not so great when you're a developer and something goes wrong on the device. From the default placeholder message I know there is a CAB...

Where is the Debug -> Exceptions window?

I must be slow or something today, I cannot find this menu option. I attached a screenshot of my IDE's Debug menu: Any ideas? ...

LINQ to SQL Auto Inserting Row Copy When Updated

Hi, I am using this simple code to try and update a row var MyDB = new SKN2DataContext(); var s_case = MyDB.SupportCases.FirstOrDefault(sc => sc.Id == 3); s_case.OpenDate = DateTime.Now; MyDB.SubmitChanges(); On the last line i am presented with the following exception Value of member 'Id' of an object of ty...