error-handling

Difference between file.is_open() and file.fail()

Initialization of file: ifstream file("filename.txt"); What's is the difference between if ( file.is_open() ) and if (! file.fail() ) ? What Should I use to make sure if the file is ready for I/O ? We assume that variable file contains a object of a file stream. ...

Incorrect data in Constructor

I have a class class Rational { private int _n; private int _m; public Rational(int n, int m) { _n = n; _m = m; } } But m should be > 0. What should I do to notify user that he enter incorrect data to constructor? ...

What to do when an out-of-memory error occurs?

Possible Duplicate: What's the graceful way of handling out of memory situations in C/C++? Hi, this seems to be a simple question a first glance. And I don't want to start a huge discussion on what-is-the-best-way-to-do-this.... Context: Windows >= 5, 32 bit, C++, Windows SDK / Win32 API But after asking a similar questio...

Show form when exception occurs C#

Hi, I have been looking at the Windows API Code Pack 1.1 and have seen a Error sample and would like to integrate it into my Application, the main idea would be for it to show if any error in the application happens, well not any but some that I choose. How can I program this? I am using WPF Thanks ...

Why stacktrace is not displayed when an exception occurs?

Hi all. I have a problem. My program crashes on start up without any stack trace. The only thing I can see is "Send Report To Microsoft". This happens only on one PC. Can you explain me Why some exceptions are with stack trace and some are without? Thanks. ...

How to display variables on error?

I am getting occasional Undefined offset issues when parsing a large file inside PHP. How can I display the variables ONLY when the error occurs, to see what the issue is? The error is occuring at this point of my php list($export_date, $application_id, $language_code, $title, $description, $release_notes, $company_url, $suppport_url,...

Missing RouteData DataTokens

I'm handling errors in ASP.NET MVC by sending an error id from Application.OnError to a controller action, by adding a route data value that gives the error id: Global.asax.cs/OnError: var routeData = new RouteData(); routeData.DataTokens.Add("errorKey", errorId); var context = new RequestContext(new HttpContextWrapper(Context), route...

python error checking

I am using code below. How Do add error checking. If anything is error, replace continue reading Ex: if volume is N\a or missing , replace with 'a value.' Don't skip line, don't stop. reader = csv.reader(idata.split("\r\n")) stocks = [] for line in reader: if line == '': continue stock, price, volume, stime = line ...

Run time error handling on lazy loaded javascript?

Does anyone have any ideas how to do error handling on lazy loaded javascript? I am using an approach in which an ajax request is called and the code is eval'd in global scope. When a runtime error is struck, it spits out the filename as my lazy loading script and the line number is the error line plus the line number of my eval in my ...

Flash AS3 Error Stack Path

Not sure how to phrase this but I'm wondering if I can create a catchall error handler that umbrellas the entirety of the code, to send to a custom handler that outputs the info graphically within the program. Something along the lines of: root.addEventListener(ErrorEvent.ERROR, this.customHandler); I'm hoping to stop any and all fr...

Try-catch exception handling practice for iPhone/Objective-C

Hi all, Apologies if this question has already been answered somewhere else, but I could not find any decisive answer when searching on it: I'm wondering when try-catch blocks are to be used in objective-c iPhone applications. Apple's "Introduction to the Objective-C Programming Language" state that exceptions are resource intensive an...

Dynamically Loading DLLs at Runtime

I'm working on a C# application that supports two communications interfaces, each supported by its own DLL. Each DLL contains the same function names, but their implementation varies slightly depending on the supported interface. As it is, users will typically have only one DLL installed on their machine, not both. The DLL for the old...

pattern match args and give error messages in a lightweight Scala script

I write a number of simple scala scripts that end up starting with a simple pattern match on args like: val Array(path, foo, whatever) = args // .. rest of the script uses "path", "foo", etc. Of course, if I supply the wrong number of arguments, I get an inscrutable error like: scala.MatchError: [Ljava.lang.String;@7786df0f at Ma...

How to continue javascript execution when receiving errors during load

Not sure the best way to phrase the question, but suppose you are using jQuery to setup various things like so: <script> function doSecond(){ alert("Hi"); } function dofirst(){ var x = asdasd; } $(dofirst); $(doSecond); </script> So, imagine that dofirst and dosecond are completely indepe...

Why is cleanup necessary if both OpenThreadToken and OpenProcessToken fail?

In the IsMemberOfAdministratorsGroup example in MSDN, there is code like this: if (!OpenThreadToken (GetCurrentThread(), TOKEN_QUERY|TOKEN_DUPLICATE, TRUE, &hToken)) { if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_DUPLICATE, &hToken)) { lastErr = GetLastError(); goto CLEANUP; } } .... CLEANUP: if (hToken...

Why finally block is not given in SQL SERVER?

All language like C#,VB.NET all have try catch finally block but SQL server only have try and catch only why not finally block is given is there any specific reason for that? ...

Getting next alarm information when there is no such function

I have this code in my app Alarm1 = Settings.System.getString(getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED); Its working on htcs,motorolas,but not on galaxy s phones.The application crashes. Would the following catch the error without crashing the application service? String Alarm1=null; try{ Al...

Error Handling in Silverlight Applications

How is the best way to handle any occuring errors in a Sivlerlight application? I am not talking about error handling in a development environment. But what would be the best way to log errors and look them up for fute reference? ...

Android service error handling

What is best way for services error handling? For example, I have service which get some information from Internt, I want show to user some dialog with message when connectivity is bad. Or if I have some Util class for parse HTML that used by my service and exception occures in this Util class. How to show dialog? As I know DialogBuilder...

How can I get better error information with try/catch in Python

Consider this try/catch block I use for checking error message stored in e. Try/Catch to get the e queryString = "SELECT * FROM benchmark WHERE NOC = 2" try: res = db.query(queryString) except SQLiteError, e: # `e` has the error info print `e` The e object here contains nothing more than the above string. When python re...