Is there Match Or Exception Regex in .NET
I would like to do something like the below but throw an exception because there is no match. Is that possible? var val = Regex.Match("nomatchplz", "notgoingtomatch(.*)").Groups[1].Value; ...
I would like to do something like the below but throw an exception because there is no match. Is that possible? var val = Regex.Match("nomatchplz", "notgoingtomatch(.*)").Groups[1].Value; ...
I'm parsing third party log files containing date/time using Joda. The date/time is in one of two different formats, depending on the age of the log files I'm parsing. Currently I have code like this: try { return DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").parseDateTime(datePart); } catch (IllegalArgumentException e) { re...
I have some code that is looking up group memberships from local groups on a machine. For each member, it tries to load some information about the user (eg. find a group and get the names of each of its members). The code: using (DirectoryEntry machine = new DirectoryEntry("WinNT://" + Environment.MachineName + ", Computer")) { usi...
A student of mine submitted some C++ code similar to the following one. The code compiles and runs, but the throw statement produces the following message: terminate called after throwing an instance of 'int' If I make the function void the compiler complains invalid use of ‘void’ on the line that contains the throw statement...
It seems to me that if you have some C++ code like this: int f() { try { if( do_it() != success ) { throw do_it_failure(); } } catch( const std::exception &e ) { show_error( e.what() ); } } The C++ compiler should be able to optimize the throw and catch into almost a simple goto. However, it seems to me from m...
Which exception should I use when the program reaches a logic state that I "know" won't happen, and if it does, something is terribly bad. For example: int SomeFunction(int arg) { SomeEnum x = Whatever(arg, somePrivateMember); switch (x) { case SomeEnum.Value1: return SomeFunction1(); case SomeEnum.V...
We are calling ExecuteNonQuery on all files in a certain folder for version scripting and if there is a syntax error an exception is raised. I have been scanning MSDN for a way to get the line number but haven't been able to find anything yet. There is a 'SqlException' class which does contain the line number but the shared base class 'D...
Hi, I get the below stack trace when I hit a servlet that retrieves some information from a database and populates a html template. I'm unclear if its an issue with writing to the disk or the connection to the browser? java.io.IOException: Stream broken at org.apache.tomcat.service.connector.AJP12RequestAdapter.readNextRequest(Ajp12Co...
How will I be able to count the number of exceptions thrown during the execution of a service? Right now I'm using behaviors to hook with the dispatchers using IOperationInvoker and IParameterInspector. But I need to know how can i count the faults and exceptions that occurs in a particular operation or the total occurrence in the whole ...
I've written an unhandled error module for my iPhone app, but for some reason some errors are managing to bypass it. I have an exception handler and the following signal handlers set: NSSetUncaughtExceptionHandler(&handleException); signal(SIGILL, handleSignal); signal(SIGABRT, handleSignal); signal(SIGFPE, handleSignal); signal(SIGBUS...
I have some experience with ANTLR 2's C++ target, but have been hesitant to spend much time on ANTLR 3 because of my fears about exception safety. Sadly, ANTLR 3 only has a C target which produces C which is "C++ compatible." This does not seem to include C++ exception safety, based on the following: You can probably use [exception...
I have an object on the stack for which I wish its destructor to skip some work when the destructor is being called because the stack is being unwound due to a specific exception being thrown through the scope of the object on the stack. Now I could add a try catch block inside the scope of the stack item and catch the exception in ques...
I have questioned and got solution how to break on exception in Web Inspector: http://stackoverflow.com/questions/3315675/how-can-i-get-break-on-runtime-exceptionor-error-in-javascript-or-ecmascript Thanks klaaspieter. But I faced another problem. Web Inspector broke on exception, but does not print exception message until I continue ex...
Hi, I'm developing a GUI app in c#. Its a multithread app, and I would like to wrap all the threads (some of them I don't open e.g. NetClient.StartDownload which is none blocking function) with a try/catch . Statment so that if an exception is thrown an uncought, I could log it and report to base. I tried using Application.ThreadExcep...
Can I declare a function in php that throws an exception? For example: public function read($b, $off, $len) throws IOException ...
I am writing a script which checks for a registry value and and exits if is 0. (It will proceed if the value is 1.) if ((Get-ItemProperty -path HKLM:\SOFTWARE\ICT\LoginScript).proceed -eq 0) { $form.close() exit } When I run the script with the reg value at 0, it fails to exit and throws an ex...
Hi, in a catch block, how can I get the line number which thrown an exception? ...
Let's say I have class that acts as a "smart pointer" and releases some kind of system resource when destroyed. class Resource{ protected: ResourceHandle h; public: Resource(ResourceHandle handle) :h(handle){ } ~Resource(){ if (h) releaseResourceHandle(h);//external function, probably from...
except ImportError as xcpt: print "Import Error: " + xcpt.message Gets you a deprecation warning in 2.6 because message is going away. Stackoverflow How should you be dealing with ImportError? (Note, this is a built-in exception, not one of my making....) ...
I have the following code: try { //jaw-ws service port operation port.login(); } catch (Exception e) { logger.error("Caught Exception in login(): " + e.getMessage()); } When the above is run with an incorrect hostname, I get: Caught Exception in login(): HTTP transport error: java.net.UnknownHostException: abc That is c...