Generate SoapFault without throwing an exception - soap

I know that when there is an unhandled Exception in asmx that it generates a soapFault and returns it to the client. What I want to know is if there is a way to return a soapFault without throwing an exception. Throwing an exception is an expensive operation and I would like to avoid it if I can.

AFAIK there is no such option (short from building the complete XML/SOAP message yourself that is)... with WCF this could be slightly easier IMO
You can throw a SoapException and can customize it rather thoroughly:
http://support.microsoft.com/kb/833379/en-us
http://msdn.microsoft.com/en-us/library/aa480514.aspx

Related

Kafka Streams: How to stop stream application when exception

Version 1.0
Let's say in the punctuate method of lowlevel processor, creation of a dummy file fails with an exception. How to stop the stream application when an exception is encountered?
I was wondering if there is a way to throw an exception, but could not add throw clause on the init method. The following requires to be surrounded by a try-catch OR an exception to be thrown and can't use either one. Please suggest.
Files.createFile(Paths.get(dummyFile));
you could wrap IOException into any unchecked exception like RuntimeException, or would be better to create your own that will extend from RuntimeException, and throw it. if your method throw exception for any incoming message, stream will be in a dead state, so stop consuming messages until you restart application

How to avoid handling RunTimeException in Jersey

The most popular desicion for handling exceptions in rest service and return the error message to client - as i understand - is to catch WebApplicationException or MappableContainerException. But they are extending RuntimeExceprion (I don't understand why). As I know we should avoid handling RuntimeExceptions.
I need to handle such exceptions as "The entity with such name already exsists". I'm sure it is not a runtime exception.
Any other ways? I'm researching now Wrappers. May be you could excplain me the best way to solve my problem?
The way that I handle this is to have my own exception hierarchy, and to build a separate ExceptionMapper which handles this hierarchy. That allows me to pass back whatever information I need to (in my case a JSON-formatted response) in a standardized way.
I would still have an ExceptionMapper for WebApplicationException, otherwise the end user might receive some nasty looking responses. And if you want to be extra-safe then you can also put one in for Exception that picks up anything else you might have missed (the exceptions go to the most specific exception mapper for them, so putting one in for Exception doesn't affect them).

Entity Framework Best Practice on catch exception

My Entity Framework will always targeting SQL Server.
So, in my program. What type of exception shall I catch?
DataException or SqlException ?
and in DAL, is it good to throw the exception again after logging?
I would suggest multiple catch and log both.
In live environment its not recommended to throw error to client system, however you always need to throw the error.
So its your call how to do it.
If its live show a beautiful error to client that something went wrong and we are looking.

How do I make detail of an exception thrown by IOperationInvoker visible to silverlight?

I have a set of RIA domain services that use an overriden OnError operation to throw DomainExceptions. This works perfectly and allows the silverlight client to identify the base exception types via the embedded error code. However my RIA service operations are attributed to include a number of implementaions of IOperationInvoker to inject pre-invoke and post-invoke behaviour.
If an exception is thrown by any of the code in these IOperationInvoker operations the silverlight client gets a DomainOperationException containing a FaultException. Even though the thrown exception is a FaultException the received fault appears be be devoid of any the original detail only containing the textual message.
I have tried catching the exception in the IOperationInvoker and converting it to a DomainException but this does not change what is visible in Silverlight.
Is there any way I can throw an Exception from the IOperationInvoker so that it is surfaced in the Silverlight client as a DomainException i.e. including the error code as if it had come from the DomainService operation that is wrapped by the IOperationInvoker?

error handling vs exception handling in objective c

I am not able to understand the places where an error handling or where an exception handling should be used. I assume this, if it is an existing framework class there are delegate methods which will facilitate the programmer to send an error object reference and handle the error after that. Exception handling is for cases where an operation of a programmer using some framework classes throws an error and i cannot get an fix on the error object's reference.
Is this assumption valid ? or how should i understand them ?
You should use exceptions for errors that would never appear if the programmer would have checked the parameters to the method that throws the exception. E.g. divide by 0 or the well known "out of bounds"-exception you get from NSArrays.
NSErrors are for errors that the programmer could do nothing about. E.g. parsing a plist file. It would be a waste of resources if the program would check if the file is a valid plist before it tries to read its content. For the validity check the program must parse the whole file. And parsing a file to report that it is valid so you can parse it again would be a total waste. So the method returns a NSError (or just nil, which tells you that something went wrong) if the file can't be parsed.
The parsing for validity is the "programmer should have checked the parameters" part. It's not applicable for this type of errors, so you don't throw a exception.
In theory you could replace the out of bounds exception with a return nil. But this would lead to very bad programming.
Apple says:
Important: In many environments, use of exceptions is fairly commonplace. For example, you might throw an exception to signal that a routine could not execute normally—such as when a file is missing or data could not be parsed correctly. Exceptions are resource-intensive in Objective-C. You should not use exceptions for general flow-control, or simply to signify errors. Instead you should use the return value of a method or function to indicate that an error has occurred, and provide information about the problem in an error object.
I think you are absolutely right with your assumption for Errors and for it framework provide a set of methods (UIWebView error handling ), But your assumption for Exception partially right because the exception only occurred if we do something wrong which is not allowed by the framework and can be fixed. (for example accessing a member from an array beyond its limit).
and will result in application crash.