Which of the following ways of handling this precondition is more desirable and what are the greater implications?
1:
If Not Exists(File) Then
ThrowException
Exit
End If
File.Open
...work on file...
2:
If Exists(File) Then
File.Open
....work on file...
Else
ThrowException
Exit
End
Note: The File existe...
I noticed some confusion initially with my question. I'm not asking about how to configure a logger nor how to use a logger properly, but rather how to capture all of the information that would have been logged at a lower logging level than what the current logging level is in the exception message.
I have been noticing two patterns in ...
How do I sort out (distinguish) an error derived from a "disk full condition" from "trying to write to a read-only file system"?
I don't want to fill my HD to find out :)
What I want is to know who to catch each exception, so my code can say something to the user when he is trying to write to a ReadOnly FS and another message if the user...
When adding a second WCF service to an existing WCF project, or adding a first WCF service to a project gives me a dialog box "Specified Cast Is Invalid". WCF files are added to the project except interface file. Web.Config isn't updated neither.
I think the problem started after updating VS.NET 2008 to VS.NET 2008 SP1.
...
The following code throws an InvalidCastException.
public static MachineProductCollection MachineProductsForMachine(
MachineProductCollection MachineProductList, int MachineID)
{
return (MachineProductCollection)
MachineProductList.FindAll(c => c.MachineID == MachineID);
}
This surprises me since MachineProductCollecti...
Hi All,
Just starting to get to grips with python and MySQLdb and was wondering
Where is the best play to put a try/catch block for the connection to MySQL. At the MySQLdb.connect point? Also should there be one when ever i query?
What exceptions should i be catching on any of these blocks?
thanks for any help
Cheers
Mark
...
Hello,
I'm asking for Delphi native,not Prism(net).
This is my code:
raise Exception.Create('some test');
Undeclarated idenitifier "Exception".
Where's the problem,how do I throw/raise exceptions?
...
I am getting the following error. Not getting clue why is it coming. Also i checked DB it looks fine.
Hibernate: select customer0_.CustomerId as CustomerId0_, customer0_.CustomerAlia
s as Customer2_0_ from FF_REFERENCE.dbo.Customer customer0_ where customer0_.CustomerId=?
org.hibernate.exception.SQLGrammarException: could not execute q...
Hey everyone,
I'm getting an IllegalCastException on the following (see bold line):
public void renderXML(final String xml) {
final Document xmlDoc = XMLParser.parse(xml);
final com.google.gwt.xml.client.Element root = xmlDoc.getDocumentElement();
XMLParser.removeWhitespace(xmlDoc);
final NodeList collection = root.getElementsByTa...
Hi there.
I noticed with -O2 level optimization using gcc 4.1 built on IBM AIX (for use with 5.3 and 6.1) that a bunch of lwz rxxx,offsetyyy(r2) sequences are added to an inline sequence, before bctrl (calling a method or function) is done. After the register is loaded, it is never used again after the return from the method or function...
I was debugging my current project (ASP.net MVC 1.0 project)
and stumbled upon slightly disturbing behavour.
It seems that when the router is hunting for a referenced partial view
aka
<%Html.RenderPartial("AccountListControl", ViewData["AccountList"]); %>
It cycles through it's default locations until it finds the correct spot.
So i...
I have a test winforms app with ThreadExceptionHandler that displays a message box when an unhandled exception is caught, as follows:
[STAThread]
static void Main()
{
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
Application.EnableVisualStyles();
Application.Set...
Java's checked exceptions sometimes force you to catch a checked exception that you believe will never be thrown. Best practice dictates that you wrap that in an unchecked exception and rethrow it, just in case. What exception class do you wrap with in that case?
What exception would you wrap with in the "// Should never happen" case?
...
Hi All
Is there an easy way to log all exceptions in an ASP.NET application? I'm already logging unhandled exceptions through the Application_OnError event, but I want to perform logging even when an exception is handled on a page level.
Many thanks.
...
At the company where I am right now, there are a lot of places in the code where an OurCompanyRuntimeException is thrown (where OurCompany is the actual name of the company). As far as I can tell, this exception is described as "A runtime exception thrown by code that we wrote here at this company."
I'm somewhat new to Java, but I thoug...
I'm trying to trap any and all exceptions in a C++/CLI app so that I can log and record them (including a stack trace). So far I have some code which looked promising:
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
...
Thanks!
the question is solved in all the answers given.
Original question follows:
given a traceback error log, i don't always know how to catch a particular exception.
my question is in general, how do i determine which "except" clause to write in order to handle a certain exception.
example 1:
File "c:\programs\python\lib\httpl...
Our application is using mshtml. That dll is causing our application to exit ungracefully due to well known problems in mshtml since we don't install newer browsers on users' machines. We just use what they have already.
The SetUnhandledExceptionFilter() does not handle this, nor does a try/catch block around the calls into mshtml. The...
I'm working with an SSIS Package that pulls data from a DB2 source, runs through a conversion process (unicode stuff) and then stores the data in a SQL table. From the error information below, I have been able to determine that there is some kind of special characters in the DB2 file/table. What I do not know is how I can narrow down w...
So I just spent around an hour trying to unveil and resolve a very strange bug, one that I have never seen before.
I am more or less asking for potential causes of this seeming random cast from enum to String rather than "please fix my code for me".
The gist of the problem is as follows:
I have an interface, call it IFoo, within this ...