exception-handling

How to prevent exceptions bubbling up in C#?

If I'm writing a class library, and at some point in that library I have code to catch an exception and deal with it, then I don't want anyone using my library to know that it even happened - it should be invisible from the outside world. However, if they have "Catch Thrown Exceptions" turned on in Visual Studio (as opposed to "Catch Us...

Catching SoapExceptions from ASP.net Webservices

I have a windows forms client that consumes an ASP.net web service. It's my understanding that when an exception is thrown by the web service it will be converted to a SoapException in the .net client software. Well, I am catching the SoapException, but when I display the message on the client end in a messagebox, it shows more informa...

Handing exception in BLL and return to client (either winforms or webforms)?

Hi I am looking for the best way to do exception handling, for example.. when an error occurs in the business logic layer, is the best way to stop the METHOD using a catch and return an EVENT to the presentation layer? What should this event contain? Or should i always BUBBLE up exceptions and handle them in the presentation layer? ...

C# Returning something from exception handle

Hello, I have the following code in a class of mine. The purpose of this class is to get the balance from a web server. Just in case something goes wrong with getting the balance. I will handle a exception. However, all this is easy to do. But I am left wondering what do I return in my catch statement. Most of the examples I looked at...

Ruby Exception Handling Questions

Hi, I was going through the Programming Ruby book and Im having problem understanding the following concepts: The authors talk about "transient exceptions" that may occur in the code and then suggest a creation of your own exception object to handle them. I dont think i fully understand what a transient error is and when is it appro...

problem in try statement

Hello, This is the code I use to setup my TCP server internal void Initialize(int port,string IP) { IPEndPoint _Point = new IPEndPoint(IPAddress.Parse(IP), port); Socket _Accpt = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { _Accpt.Bind(_Point); ...

System.ServiceModel.Security.MessageSecurityException occuring under ExceptionShielding

We are using the Enterprise Library 4.1 Exception Handling Application Block's ExceptionShielding feature in combination with a custom RoleProvider with our WCF services. When the RoleProvider determines an user is not in a role and returns false from the IsInRole method, the following exception is occurring: System.ServiceModel.Securi...

How exception handling mechanishm really works in .net?

I wonder, How exception handling mechanishm actualy works in .net? Just want to know, what happens in runtime internally? ...

Can I get the line of code that caused an exception?

Other than reading the GetFileName() file and reading to line GetFileLineNumber() of a stackframe from new StackTrace(exception).GetFrame(x) is there a way to get the actual line of code (as a string) which caused an exception? Thanks ...

Enterprise Library How to Implement a IExceptionHandler?

I have to implement a IExceptionHandler for the Enteprise Library 4.1. In my particular case I want to use it to log the exception to Fogbugz but the inner details is not what I am asking about. What I need is how to - best practicies - implement it, How to get the config for a app.config or web.config. etc. I have code This so far: ...

What's a good way for a c# dll to return error to the calling application?

Hi guys, i'm writing a dll which is a wrapper to a access database. and i'm pretty new to c# in general as my background is in web development LAMP with perl, i'm not sure what's a good way to return error to a calling app in case they pass the wrong parameters to my functions or what not. I have no idea as of now except to probably do ...

Why does the code execution never enter the catch block (java)?

I am trying to throw a (custom) ImportException from the method importUsers in class UserHelper. I can see in the debugger that the throw clause is executed, but the method, from which the importUsers method is called, never catches the exception. Here is the method, where the exception is thrown: public static AccessorValidator impor...

Should methods that throw RuntimeException indicate it in method signature?

For example, many methods in frameworks/JDK might throw java.lang.SecurityException but this is not indicated in the method signature (since that is a practice normally reserved for checked exceptions). I want to argue that declaring RuntimeExceptions in method sigs has many benefits (akin to static type checking for example). Am I d...

Why have a project specific RuntimeException?

Is there any point in having a com.myco.myproj.MyProjRuntimeException, which completley extends RuntimeException? ...

Should Exceptions be placed in a separate package?

I am taking on a project where all the Exceptions have been placed in a separate package com.myco.myproj.exceptions. Is this good practice? ...

Catch only some runtime errors in Python

I'm importing a module which raises the following error in some conditions: RuntimeError: pyparted requires root access I know that I can just check for root access before the import, but I'd like to know how to catch this spesific kind of error via a try/except statement for future reference. Is there any way to differentiate betwe...

design for handling exceptions - google app engine

I'm developing a project on google app engine (webapp framework). I need you people to assess how I handle exceptions. There are 4 types of exceptions I am handling: Programming exceptions Bad user input Incorrect URLs Incorrect query strings Here is how I handle them: I have subclassed the webapp.requesthandler class and overrode...

How to handle errors for a facade method that performs many disparate background changes ?

Imagine I have a service that looks like this: public interface MyAccountService { boolean create( String user ); } The method create performs several changes, namely (for discussion sake): adds a message into a Queue adds a row into several tables creates a LDAP account etc... Currently I collapse all the error messages into ...

VB 2008 -- Exception handling in property for ambiguously typed data coming from web service

Hi, I need to consume data from a webservice. I am receiving xml data and using this to create objects through property setters. In one particular case, an attribute of the object (called "is_active" and indicates whether the object is active or inactive in the application) is represented sometimes by <field type="BooleanField" name="...

Exception Handling Standards Advice

In the j2ee applications I plan on standardizing the exception handling strategy. No more swallowing exceptions and basically converting all checked exceptions into unchecked (except for some that actually can be recovered from. The standard will be that all Exception will be thrown back up to the container (eg: http://www.onjava.com/pub...