exception-handling

Trapping errors in TClientDataSet.CommandText

I have a TClientDataSet connected to a TDataSetProvider, which in turn is connected to a TAdsQuery. I set the SQL command and then open the ClientDataset something like this: try CDS.CommandText := 'SELECT * FROM tablename WHERE fieldname = 1'; CDS.Open except // trap exception here - this never gets executed! end; If the SQL st...

wxWidgets exception handling

When unhandled exception is handled in wxWidgets application in Windows, program shows Abort-Retry-Ignore message produced by Widgets exception handler. I want to get normal unhandled exception behavior: program should terminate with standard Windows unhandled exception dialog. Can I prevent Widgets to catch unhanled exceptions? ...

Parsing RSS2.0 feeds using Pull Parser on Android

I am trying to parse a RSS2.0 feed, obtained from a remote server, on my Android device using XML Pull Parser. // get a parser instance and set input,encoding XmlPullParser parser = Xml.newPullParser(); parser.setInput(getInputStream(), null); I am getting invalid token exceptions after a few items have been parsed: Error pars...

php: handling exceptions within exception handlers?

Let's say were using custom extensions of the Exception class to handle custom exceptions, like this for example: $testObject = new testClass(); and a autoload like this: function __autoload($class_name) { $file = $class_name.'.php'; if (file_exists($file)) { include $file; }else{ throw new loadException...

php: autoload exception handling.

Hello again, I'm extending my previous question (Handling exceptions within exception handle) to address my bad coding practice. I'm trying to delegate autoload errors to a exception handler. <?php function __autoload($class_name) { $file = $class_name.'.php'; try { if (file_exists($file)) { include $file; ...

Catch a thread's exception in the caller thread in Python

Hi Everyone, I'm very new to Python and multithreaded programming in general. Basically, I have a script that will copy files to another location. I would like this to be placed in another thread so I can output .... to indicate that the script is still running. The problem that I am having is that if the files cannot be copied it wi...

Detecting a Dispose() from an exception inside using block

I have the following code in my application: using (var database = new Database()) { var poll = // Some database query code. foreach (Question question in poll.Questions) { foreach (Answer answer in question.Answers) { database.Remove(answer); } // This is a sample line that simulate an err...

Is it best practice to try - catch my entire PHP code, or be as specific as possible?

I do not have many kinds of Exceptions in my project. Right now,(we use MVC) I have the try catch encompassing my entire code: try{ fronController::dispatch($somthing...); }catch(Exception $E){ //handle errors } I wonder if there is a good reason to use the try-catch block in as specific as possible way as I can or just keep it g...

Displaying and capturing c# exceptions

I have a c# program which throws a NullReferenceException(). When I start this on my Vista machine, it gives the familiar screen "Foo has stopped working". I can easily click on 'details' to see what went wrong. On one XP machine there's no warning at all: the program just quits, and on another XP I get the "Foo has encountered a problem...

Activation Error while testing Exception Handling Application Block

I'm getting the following error while testing my EHAB implementation: ArgumentException - Event log names must consist of printable characters and cannot contain , *, ?, or spaces The stack trace was: {"Activation error occured while trying to get instance of type ExceptionPolicyImpl, key "LogPolicy""} System.Exception Sta...

How to catch an exception thrown in ctypes?

I am working with some C code called from Python using ctypes. Somewhere in the bowels of the C library, an exception is occurring and/or abort() is being called. Is there any way I can catch this in my Python caller code? (Platform is Linux) ...

Java Runtime Exception

when i run my application i get the following error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.text.FlowView$FlowStrategy.layoutRow(FlowView.java:546) at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:460) at javax.swing.text.FlowView.layout(FlowView.java:184) at ja...

Which of the two exceptions was called?

If I have a routine that can throw an ArgumentException in two places, something like... if (Var1 == null) { throw new ArgumentException ("Var1 is null, this cannot be!"); } if (Val2 == null) { throw new ArgumentException ("Var2 is null, this cannot be either!"); } What’s the best way of determining in my calling procedure w...

Rescuing a failed WCF call

Hello, I am happily using Castle's WcfFacility. From Monorail I know the handy concept of Rescues - consumer friendly results that often, but not necessarily, contain Data about what went wrong. I am creating a Silverlight application right now, doing quite a few WCF service calls. All these request return an implementation of public ...

How to catch this type of exceptions ?

I'm starting getting tired of this exception. Can't handle it, even so I'm using this: AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Still no success, Can anyone explain me, how I should handle it in a nice way. Or how to detect that it have fired this message and cl...

How to: generate UnhandledException?

I use this code to catch the WinForm application UnhandledException. [STAThread] static void Main(string[] args) { // Add the event handler for handling UI thread exceptions to the event. Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); // Set the unhandled ...

How to make a thread try to reconnect to the Database x times using JDBCTemplate

Hi, I have a single thread trying to connect to a database using JDBCTemplate as follows: JDBCTemplate jdbcTemplate = new JdbcTemplate(dataSource); try{ jdbcTemplate.execute(new CallableStatementCreator() { @Override public CallableStatement createCallableStatement(Connection con) throws SQLException { ...

How do you catch a MySQLIntegrityConstraintViolationException correctly?

I am working on a web application, and at a point where I submit forms that are unique to the user, a MySQLIntegrityConstraintViolationException Duplicate entry -'username' for key 'PRIMARY' I am well aware of why this is being thrown, because I am attempting to enter a duplicate entry into the database with the same primary key. I wo...

@ExceptionHandler doesn't handle the thrown exceptions

Hello, I have a method in my controller which will handle the exceptions thrown by the application. So I have a method like this one. @Controller public class ExceptionController { @RequestMapping(value="/error") @ExceptionHandler(value={Exception.class, NullPointerException.class}) public String showError(Exception e){ ...

How can I use ExceptionNotifier in my models?

I have a transaction in one of my model. When something go wrong, I want to be notified. If it would be transaction in controller, I would simply do: begin (my transaction...) rescue => exception ExceptionNotifier.deliver_exception_notification(exception, self, request, data) end But I want to do similar thing in my model, passin...