Hi!
We have a WebForms Control which requires that the ID of another Control implementing ITextControl is provided.
What exception should we throw if there is no control with that ID or a control is found but it's not implementing the interface?
var text = Page.FindControl(TextProviderId) as ITextControl;
if (text == null) {
throw...
If an exception occurs in my WCF service, what is the best way to communicate that error to the client?
Should I log it on the service and rethrow a soap exception?
Or should I log it and return a user friendly message?
...
Why is it preferable to throw this Exception
Throw New DivideByZeroException("You can't divide by zero")
over this general one:
Throw New Exception("You can't divide by zero")
What advantage is gained in this particular example? The message already tell it all. Do standard subclasses that inherit from the base Exception class ever ...
I have a single-threaded IronPython WPF application and if an event handler (FrameworkElement.SizeChanged for example) throws, the exception is just eaten and execution continues without any kind of notification.
Because of this I spent a lot of time today solving an "impossible" bug.
Does the same thing happen when using WPF from C#? ...
I am unable to connect to mySQl db using pyodbc.
Here is a snippet of my script:
import pyodbc
import csv
cnxn = pyodbc.connect("DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost;DATABASE=mydb; UID=root; PASSWORD=thatwouldbetelling;")
crsr = cnxn.cursor()
with open('C:\\skunkworks\\archive\\data\\myfile.csv','r') as myfile:
rows...
what is the best way to handle an exception?
and why should i never write:
catch (Exception ex) { throw ex; }
...
Hello everyone,
when implementing/using methods that return or work with instances of objects, what is the most elegant approach to check the function parameters ?
Method to call:
someType GetSomething(object x)
{
if (x == null) {
return;
}
//
// Code...
//
}
or better:
someType GetSomething(object x)
{...
In my app I want to use $this->forward404("Data not found"); to output individual error messages when necessary.
In the dev mode it works fine. When I run my app in production mode - where debug is set to false in getApplicationConfiguration() - I don't get the messages anymore.
in settings.yml I set a custom 404 action.
all:
.actions...
Hello,
I have a simple class that handles the connection being made between a client and server.
To let more than one user communicate with the server at one time each new Client connection is made on a separate thread.
In this class I create two streams that act as the inbound and outbound streams for the client. I create the fields ...
A similar question was asked here, but as the answers didn't answer my question, I'm asking:
I've almost never used trigger_error, always thrown exceptions instead, since in my mind errors are legacy. But I've changed my mind, I think they can co-exist. There are cases when triggering errors make more sense.
I'm updating this library, ...
Getting the (hex) error code from an IOException, or regular Exception!
Is this possible? i know it HAS a error code, (HResult) but the get accessor is private.
I would do some sort of ComException thing, but im not sure about the pros/cons of doing this, and if its even possible/the same.
...
Assume I have method that reads customers from a csv file.
When reading the file an exception occurs (e.g. IOException or FormatException). In most cases the method can't do anything about the errors but it can add extra information like file name, line number etc.
The method's class got an IProgressAndErrorReporter dependency that is ...
Hi!
Is it a good practice to catch all exceptions and re-throw them as a specific type -basically to classify all the exceptions thrown from a particular part (or service) of an application?
Something like:
// This class is used to label all the exceptions occured on
// Race Cars Service calls as RaceCarsServiceException
public clas...
Possible Duplicate:
Python try-else
Comming from a Java background, I don't quite get what the else clause is good for.
According to the docs
It is useful for code that must be
executed if the try clause does not
raise an exception.
But why not put the code after the try block? It seems im missing something importan...
With having the with statement, is there ever a need to open a file/check for exceptions/do manual closing of resources, like in
try:
f = open('myfile.txt')
for line in f:
print line
except IOError:
print 'Could not open/read file'
finally:
f.close()
...
Does python 2.5 allow you to pass exception arguments?
try: raise Exception("argument here")
except Exception: print Exception.args
I've had no luck with the above code - I know this is how you do it in Python 2.7 - is this not in Python 2.5?
...
I've noticed that Exception.pm and Error.pm don't seem to be extensively used in the perl community. Is that due to the large footprint of eval for exception handling? Also perl programs appear to have a much more lenient policy regarding exception handling in general. Is there a compelling reason for this? In any event what would be...
HI, guys.
I am using cmd and optparse to develop a CLI.py for a collection of already-functional classes (CDContainer, CD, etc.). The following are some parts of the code. I have a problem here. when there are exceptions(wrong input type or missing values), the optparse will exit the whole program instead of the specific command method...
We are trying to figure out a way to modify WCF service behavior to catch all exceptions and instead of returning faults to the client, it will populate a custom return object with exception data and return that. So far, we haven't had much luck. I found this example: Catching custom faults
However, it doesn't return custom types as we ...
hi,
Here's a situation, i have a list of support tickets that when you click the title of the ticket takes you to a page that displays the ticket in more detail. If uses URL GET variables to query the database. I've taken SQL injection into account but what if someone modifies the url to an id that doesn't exist? whats the best way to d...