The requirement:
On an error (thrown exception), the file being processed should be moved to the folder for files with errors (app.config setting).
The problem:
The only way that I can of handling this is to have a nested Try/Catch inside of the main Try/Catch to try to move the file, that way if the move fails, another exception is...
Catching an exception that would print like this:
Traceback (most recent call last):
File "c:/tmp.py", line 1, in <module>
4 / 0
ZeroDivisionError: integer division or modulo by zero
I want to format it into:
ZeroDivisonError, tmp.py, 1
...
(Win32 platform c++)
Using __try and __finally, how can I get the module name (And address) of the cause for an exception? I call GetExceptionInformation() but from that I am not sure where this information is.
Given other resources online and in MSDN the Minidump handlers and other sample code seem to be able to get it, but I am not...
Ii have a web method that looks like this:
[WebMethod]
public int ImportData(System.Collections.Generic.List<Record> importRecords)
{
int count = 0;
if (importRecords != null && importRecords.Count > 0)
{
DataLayer datalayer = new DataLayer();
foreach (Record rec in importRecords)
{
datala...
I have a simple Perl script which runs as a Linux daemon using an infinite loop. It connects to a database every 10 seconds to execute a process.
while (1)
{
# THIS LINE WILL KILL THE SCRIPT IF IT FAILS
my $DB=DBI->connect("dbi:Sybase:server=myserver","user","password");
. . . do something . . .
sleep (10);
}
I have tw...
Is it possible to change this code, with a return value and an exception:
public Foo Bar(Bar b)
{
if(b.Success)
{
return b;
}
else
{
throw n.Exception;
}
}
to this, which throws separate exceptions for success and failure
public Foo Bar(Bar b)
{
throw b.Success ? new BarException(b) : new FooException...
I have one crash in my iPhone application that does throw an NSException. The crash reports are completely ambiguous in where the error is and what exactly is causing it. Is there a smart way for me to set a top level exception handler somewhere to see what is causing it? I can't replicate the problem myself, but a few of my beta users c...
I'm currently using such blocks of code in my project
public ActionStatus GetStuff(out output)
{
try
{
if(!validation)
return ActionStatus.DataInvalid;
//do possible error stuff here
output = data;
return ActionStatus.Successful;
}
ca...
I am confused. Whether to create a custom exception or .Net base class library has the relevant exception?
I am calling some kind of service or framework API and it returns back a null reference which is an exceptional case for my tier. I know that the system won't be able to proceed with null reference and I should get a NullReferenceE...
Are there any ELMAH- or crashkit-like exception-logging FOSS packages?
Specifically, these are exception-logging applications; the code you write pushes exception reports to these systems so they can be logged, grouped, searched, and acted-upon. Both apps help with the approach of Exception Driven Development (not a fan of the phrase, ...
From this question, I'm now doing error handling one level down. That is, I call a function which calls another larger function, and I want where it failed in that larger function, not in the smaller function. Specific example. Code is:
import sys, os
def workerFunc():
return 4/0
def runTest():
try:
print workerFunc()
...
How do I get the Exception Handling Application Block (EHAB) to write the values from the Exception.Data property in the log?
try
{
// ...
}
catch (Exception ex)
{
ex.Data.Add("Hello", "World");
throw ex;
}
The exception is logged correctly, but I can’t find the added data anywhere in the log entry created by ...
I am using JDK1.6_14. This is a generic question though.
When to go for error handling and when to go for exception handling?
For example, when I carry a division operation out, I can either check if the denominator is zero and throw an error or just handle ArithmeticException.
But when to go for which method?
Thanks.
...
I have a GridView that is inside of an UpdatePanel. I am using the RowCommand event to insert data, but currently if an exception is thrown, it is not being written to the trace like I want. Is there a way I can output the exception message when using the asynchronous postback?
...
Example:
myEnumerable.Select(a => ThisMethodMayThrowExceptions(a));
How to make it work even if it throws exceptions? Like a try catch block with a default value case an exceptions is thrown...
...
I have a web service in which I have created a custom exception. Let's say the name of this exception is InvalidContractException.
What I would like to do is if a specific step occurs, I want to throw this exception. However, I can't figure out how the client would catch the InvalidContractException in order to handle it properly. ...
Disclaimer, I'm from a Java background. I don't do much C#. There's a great deal of transfer between the two worlds, but of course there are differences and one is in the way Exceptions tend to be thought about.
I recently answered a C# question suggesting that under some circstances it's reasonable to do this:
try {
some work
} c...
Using the Application.ThreadExceptionEventHandler, is it possible to determine which thread caused the exception (the thread id)?
The same question applies to using the AppDomain.UnhandledExceptionEventHandler to catch non-UI thread exceptions.
If the answer is no, is there any other way to determine which thread raised the unhandled e...
This is related to a previous question.
What I'm trying to understand now is how come UI thread exceptions can be prevented from terminating the application while non-UI exceptions can't be.
For reference, see this example.
Most importantly, what I would like to be able to do in that case is "silently" terminate the process - without ...
Is there a usable equivalent of AppDomain.UnhandledException for Silverlight? I say usable, because, although the method exists in Silverlight, MSDN has it marked as SecurityCritical.
What I'd like is to receive notification of Exceptions happening on background or ThreadPool threads so that I can log them. Application.UnhandledExceptio...