exception

Unable to catch exception

Why doesn't the following print "Error!" but only prints the 'failed to open stream...' warning? try { file_get_contents('www.invalid-url.com'); } catch (Exception $e) { echo 'Error!'; } ...

Exception or Error Code Enum

Recently I'm refactoring a .net program which will use a custom usb device. The device comes with a dll for communication. The dll is written in c and by checking the header, it defines a set of error return codes. The first step to comminicate with the device is to open the device. In dll, the open function looks like this: // retu...

Passing Exception Types down through a menu.

So I've come across this problem and I can't seem to solve it. Basically I've got a menu of tests, it can be of arbitrary depth, it's just a way of organizing tests and at the lowest level has specific test-cases. As it stands right now everything seems to work, however I'd like to implement a system where you can specify an exception ...

[Android SDK] Throw a custom exception from a service to an activity

Hi, I'm currently working on an XMPP app' on Android and I'm pondering about the best way to throw a different type of Exception than a RemoteException to my activity from my service. As it seems impossible to throw another thing than a RemoteException using IPC (you can't declare to throw anything in your .aidl), I just see two soluti...

HTTPS hostname wrong: should be <sub.domain.com>. What causes this?

I am getting this 'HTTPS hostname wrong:' error when trying to connect to a server using https. My url looks something like this https://sub.domain.com/tamnode/webapps/app/servlet. I connect using the following code // Create a URLConnection object for a URL URL url = new URL(requestedURL); HttpURLConnection.setFollowRedirects(fal...

Should I use an exception in this case?

I've designed a simple program that has a counter class and inside that counter class I have methods that increment the count, deincrement the count, and so on. I then present a menu to the user and have them enter their choice, ex. enter 1 for option one, etc. Well, I don't ever want the count to be negative, so to handle this I had my...

How do you catch a thrown soap exception from a web service?

I throw a few soap exceptions in my web service successfully. I would like to catch the exceptions and access the string and ClientFaultCode that are called with the exception. Here is an example of one of my exceptions in the web service: throw new SoapException("You lose the game.", SoapException.ClientFaultCode); In my client, I tr...

If i dont catch exception on Server side in WCF, will it crash the server side app?

as the title, should i catch exception on server side? ...

When is best to use exceptions in PHP?

I usually indicate an error in a method by returning false, but it doesn't always gel with me semantically (as depending on the method, false may be a valid return). I've looked into exceptions, and am wondering are they a one-size-fits-all solution? Should I return false where I can still? I may be completely missing the point here so...

Transaction count exception in vb.net (SQL Exception)

I am getting below exception when i am going to enter record in a table through StoredProceduer of sqlserver i have a field which i need u update immediately after insert of new record in table. for that i created a sotredprocedure in which i wrote insert command first and after that i wrote a update command for same recored but it gave ...

C# TCP/IP Client having an IO Exception.

The IO Exception: "Unable to read data from the transport connection: An established connection was aborted by the software in your host machine." The code has been copied from a tutorial and I'm sure that this error has something to do with my own machine. All of my firewalls, ESET and Windows, are off. The clients connect via port 555...

Which MVC Validation Framework

Hi, I have been evaluating xVal as framework for validating Entities in the ASP.Net MVC Framework. I have recently discovered that each time a validation rule is broken, xVal cause an excpetion to be thrown. To me is seems incorrect. For example, when a user fills in a form, and forgets to fill three required fields , three exceptions w...

Exception Handling in SCSF

I have a SCSF application i am trying to handle most of the exceptions using Application.ThreadException += new ThreadExceptionEventHandler(new ThreadExceptionHandler().ApplicationThreadException); The event handler :- public class ThreadExceptionHandler { public void ApplicationThreadException(object sender, ThreadExcept...

Break on NaNs or infs

Hello all, It is often hard to find the origin of a NaN, since it can happen at any step of a computation and propagate itself. So is it possible to make a C++ program halt when a computation returns NaN or inf? The best in my opinion would be to have a crash with a nice error message: Foo: NaN encoutered at Foo.c:624 Is something li...

Get exception context in PHP

If you use a custom error handler in PHP, you can see the context of an error (the value of all variables at the place where it occurred). Is there any way to do this for exceptions? I mean getting the context, not setting an exception handler. ...

PHP SimpleTest - Handling Exceptions

Hi, I have a few simple classes used in a forum application. I'm trying to run some tests using SimpleTest, but I'm having problems with exceptions. I have a section of code which generates a custom exception. Is there a way to catch this exception in my test and assert that it is what I expect? This is the method within my class: p...

How do I show a dialog after the Thread has encountered an uncaught exception?

I want to detect when an uncaught exception has happened in my Android app. Once detected, I want to display a confirmation dialog How do I get this confirmation dialog to display? When I tried various techniques, the UI is unresponsive and appears to be frozen. My code responds to this: //new CatchAllExceptionHandler(this) is my cust...

WCF Error Handling without fault contract

I have a WCF service which all operations return type is OperationStatus: [DataContract] public abstract class ServiceResponse { [DataMember] public bool Success { get; set; } [DataMember] public String StatusReason { get; set; } } I'd like to create an ErrorHandler to catch all exceptions and then I'd like it to ret...

Appropriate use of exceptions?

We are developing a collection class for a specialized PHP application. In it, there are functions named map, each, etc. A debate has been brought up about calling some functions with a bad argument. For example: public function each($fn) { // ... } // ... $collection->each('not a function'); Should the call to each throw an ...

Math.sqrt(-5) -> Force Exception in JSP?

I've 3 .jsp files. index.jsp and sqrtcalculator.jsp and error.jsp. In index.jsp there's a text field and a button. In sqrtcalculator.jps there's the, well, calculator. Now, when I leave the field empty and press the button, an expection is called, because the field is empty. And I can then reroute to an individual error.jsp site to dis...