In Tomcat, I wrote a ServletContextListener which will start an ExecutorService during startup and terminate it when it is unloaded.
I am following the example in the javadoc for ExecutorService
public void contextDestroyed( ServletContextEvent sce )
{
executor.shutdown();
try
{
executor.awaitTermination( 50, TimeUn...
I have a piece of code like this
try
{
RegistryKey regKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\xxxx\\yyyyy");
// more code
}
catch
{
}
I don't like the use of the empty catch block. But, it's useful because if the user don't have permissions to access the Registry, nothing should be done.
This piece of code ge...
Given that I have a custom PHP error handler already, does it make sense to define an exception handler as an "forwarder" like this:
function exception_handler(Exception $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
}
set_exception_handler('exception_handler');
The idea is to utilize the already existing error handler to ha...
Hi, currently I have this client code in my PHP MVC web app:
try {
BookMapper::insert($book);
} catch (DbUniqueConstraintViolationException $e) {
$errorList->addMessage($book . " already exists!");
}
I'm wondering is it bad practice to refer to the low-level framework Db* exceptions to my client code? If so, should I adjust my mo...
Hello,
I am embedding a c++ library (binding done with SIP) in my python application. Under certain circonstances (error cases), this library uses exit(), which causes my entire application to exit.
Is there a way to catch this event, or do I need to modify the library to handle error cases differently ?
Thank you very much,
...
I have a few applications which use a single Web Service which resides on the same server as the applications.
Why would only one of the applications have a problem connecting to a web service? And is there a way I can better diagnose exactly what the problem is with the connection?
It won't even connect to a web service the applicatio...
After solving all authentication related problems in my first Spring web application I'm now stuck with authorization.
Configuration using @Secured annotations is pretty straight-forward so I don't think I made a mistake here. Additionally I'm using an Active Directory using the LDAP authentication provider and assign roles by AD groups...
I’m from a .NET background and now dabbling in Java.
Currently, I’m having big problems designing an API defensively against faulty input. Let’s say I’ve got the following code (close enough):
public void setTokens(Node node, int newTokens) {
tokens.put(node, newTokens);
}
However, this code can fail for two reasons:
User passe...
This question covers a broad range of programming languages; however, I am specifically working with Python in this case.
I would like to create some user defined exceptions, but I'm not sure how fine-grained they should be. For example, if I have the following class:
class Race(object):
def __init__(self, start_time, end_time):
...
I am trying to find out the best way of handling exceptions, I have a number of layers to my application and started to use a return type of BOOL i.e. if it fails then return False and if it succeeds return True..
This works great in methods like SaveMyRecord(somerecord); as i am passing in values and don't require anything returned so...
This question is not a technical but a historical one. I was just thinking today that I've also thought of Java as the "first" language to use exception handling, until I realized that my reason for thinking this way is probably because Java was the first language I encountered that used it, but I had no historical data to back up that c...
I dont even know what caused it in my application. What is it? I created a new instance of a class (the class was in another file), but at the first time I call a method it throws a StackOverFlow exception.
The only thing that I think would logically throw a stackoverflow exception would be if someone downvoted Jon Skeet.
But seriously...
I was wondering what kind of exception should one throw for missing data. For example if an xml node doesn't contain data. It would be easy to "throw new Exception(...)" but this is not recommended. Another option would be to create a new exception class like MissingDataException or InvalidDataException but isn't there a built-in excepti...
What techniques can I use to avoid exceptions in C++, as mentioned in Google's style guide?
...
Our current deployment strategy is to deploy all assemblies with each application / service but control where *.exe and service implementaion assemblies are deployed. With that in mind, I have a specific service that when I deploy 2 unreferenced resource assemblies I get a compilation error. System.IO.FileNotFoundException: Could not l...
$.ajax(error:function(XMLHttpRequest, textStatus, errorThrown)
{ XMLHttpRequest.statusText })
Did someone also met this problem?
EDIT
I'm using Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.2) Gecko/2008091620 Firefox/3.0.2
...
Hello.
When trying to use SPWeb.GetSiteData(SPSiteDataQuery) (Trying to bind some data to SPGridView), it throws me an TargetInvocationException with a following stacktrace:
Exception
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTyp...
I have a static class that creates several worker threads in its constructor. If an exception occurs before the workers have been created my Application.ThreadException handler (used to shut the app down if an error not known to be recoverable occurs) triggers normally and everything is fine. Once the first worker thread has been creat...
The situation is that I have a dynamic library written in C++ that is wrapped for Python by another dynamic library, also written in C++ (generated by SIP to be specific). The first dynamic library defines a function do_raise, which throws an exception RaiserError, a subclass of std::exception. The second dynamic library, in wrapping do_...
Apologies up front, because this isn't a question but a solution - but it took a lot of searching to find out the answer and google wasn't much help, so I wanted to give something back to the community by providing the error and the solution to help future googlers.
When using LINQ to SQL, I ran into a problem when submitting changes (t...