exception

In Google's Protocol Buffers, what is a suitable protocol file/model for Exceptions?

Protocol Buffers doesn't have a native Exception type. What would a suitable .proto file for cross-language exceptions look like? ...

I need help solving a rather weird error in a WCF service.

Hi.. I have a solution that contains three projects. A main project with my MVC app, a silverlight application and a (silverlight enabled) WCF service project. In my silverlight project i have made a Service Reference to my WCF service. And i pretty much got that working. In my WCF service i have a method that returns an Book object, ...

Index out of bounds error

Hello, I am working on a program where i am recreating the saved widgets back on to the boundary panel. When i am creating them i am also trying to put the values into the ArrayList so that if i want to update and save the opened project i should be able to do so by getting the values from the ArrayList. Here is how the code looks like...

FileNotFound exception when trying to write to a file

OK, I'm feeling like this should be easy but am obviously missing something fundamental to file writing in Java. I have this: File someFile = new File("someDirA/someDirB/someDirC/filename.txt"); and I just want to write to the file. However, while someDirA exists, someDirB (and therefore someDirC and filename.txt) do not exist. Doi...

Which Exception class to choose

Suppose you want to throw Exception like this: 'Project with the provided ID cannot be assigned.' and you don't want to write your custom Exception class. What predefined Exception class would you use for this? (I'm talking about all classes inheriting from Exception) ...

Stack Trace of cross-thread exceptions with Invoke

When an exception happens after calling Invoke, .NET shows the stack trace as if the error happens while calling Invoke. Example below: .NET will say the error happen in UpdateStuff instead of UpdateStuff -> BadFunction Is there a way to catch the "real" exception and show the correct stack trace? Private Sub UpdateStuff() If (Me...

Creating double-clickable 'uber' jar that pulls in other jars of a spring application

Hi All, I have a mavenized, multi-module spring-based(3.0.1) application that runs in tomcat. I'm trying to create a standalone tool that I can distribute to users via a single jar(so they can just double-click on it), that bundles in some of the modules of the application mentioned above. I've used the maven-shade-plugin to assemble ...

"Randomly" occurring errors...

Hi, My website has a setup whereby when the application starts a module called SiteContent is "created". This runs a clearup function which basically deletes any irrelevant data from the database, in case any has been left in there from previously run functions. The module has instances of Manager classes - namely RangeManager, Collect...

Exception design: Custom exceptions reading data from file?

I have a method that reads data from a comma separated text file and constructs a list of entity objects, let's say customers. So it reads for example, Name Age Weight Then I take these data objects and pass them to a business layer that saves them to a database. Now the data in this file might be invalid, so I'm trying to figure ou...

FormattedException instead of throw new Exception(string.Format(...)) in .NET

I have been thinking of a good generic exception object that would replace throw new Exception(string.Format("...",...)), to both simplify and also to speed up such objects. The formatting by slow String.Format() should be delayed until Message property is called. Serialization is also somewhat risky. Also, such object could later implem...

AutoMapper index out of bounds exception in MappingEngine.cs

Currently we are running AutoMapper 1.0.1.156 in production on a WCF webservice and after about a week or so we will start to get the following error (note this was also happening in 0.4.0.126 but we couldn't get a stack trace because we only had the .dll from codeplex and no .pdb): Trying to map DataAccess.Call to DataTypes.Call. ...

What is the analog for .Net InvalidOperationException in Python?

What is the analog for .Net InvalidOperationException in Python? ...

When to throw exceptions?

Exceptions are wonderful things, but I sometimes worry that I throw too many. Consider this example: Class User { public function User(user){ // Query database for user data if(!user) throw new ExistenceException('User not found'); } } I'd argue that it makes as much sense to simply return false (or set all us...

Delphi Exception handling problem with multiple Exception handling blocks

I'm using Delphi Pro 6 on Windows XP with FastMM 4.92 and the JEDI JVCL 3.0. Given the code below, I'm having the following problem: only the first exception handling block gets a valid instance of E. The other blocks match properly with the class of the Exception being raised, but E is unassigned (nil). For example, given the curre...

WPF custom BalloonTips problem with multithreading

Hi, I have read other related question but i cant really get them to relate to this so I thought it were best to ask, Im pretty new to WPF and so on so please bear with me. I am using this http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx api to work with custom WPF Windows (in particular FancyBalloon). However, i'm coming across ...

C#: Exception to throw when a certain type was expected

I know this sort of code is not best practice, but nevertheless in certain situations I find it is a simpler solution: if (obj.Foo is Xxxx) { // Do something } else if (obj.Foo is Yyyy) { // Do something } else { throw new Exception("Type " + obj.Foo.GetType() + " is not handled."); } Anyone know if there is a built-in exce...

SQLITE problem in rowid

I am using SQLite C# library and as per my requirement, before going to add I am retreving the rowid of that table. It is working fine but hetting error when table is empty. Once we add any data(a row) then it’s working fine . mDbCon = GetConnection(); SQLiteCommand cmd = mDbCon.CreateCommand(); cmd.CommandTex...

Is there a way of recover from an Exception in Directory.EnumerateFiles ?

In .NET 4, there's this Directory.EnumerateFiles() method with recursion that seems handy. However, if an Exception occurs within a recursion, how can I continue/recover from that and continuing enumerate the rest of the files? try { var files = from file in Directory.EnumerateFiles("c:\\", "*.*", SearchOpti...

How should I use try...except while defining a function?

Hi all, I find I've been confused by the problem that when I needn't to use try..except.For last few days it was used in almost every function I defined which I think maybe a bad practice.For example: class mongodb(object): def getRecords(self,tname,conditions=''): try: col = eval("self.db.%s" %tname) ...

NserviceBus throws exception when referencing a Nettiers assembly

We use nettiers as a our data layer, and we recently have started looking at using NServiceBus, but we have hit a wall. We have a windows service which hosts NSB and references our Nettiers assembly. the service is throwing an exception when the following line is encountered. var Bus = Configure.With().SpringBuilder() .Xml...