Coldfusion: How to handle cfftp exceptions - exception

I'm using Coldfusion version:8. I need to handle cfftp exceptions, which handles invalid credentials, connection timeout, no upload permissions, no delete permissions. what is the exact defined runtime exception for cfftp tag in Coldfusion.

Try using cftry tag:
<cftry>
FTP code here.
<cfcatch type="exception type1">
Add exception processing code here.
</cfcatch>
<cfcatch type="exception type2">
Add exception processing code here.
</cfcatch>
<cfcatch type="Any">
Add exception processing code appropriate for all other exceptions here.
</cfcatch>
</cftry>
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Errors_13.html

Exception handling isn't going to help you if your request is served by the targeted webserver. Exceptions are only thrown if something unexpected occures while trying to send the request by ColdFusion, i.e. outgoing firewall blocks your request or any other kind of connection issue.
The only thing you need is the CFHTTP struct variable that is always generated after calling the tag. This struct contains all data related to the actual HTTP response. (Keeping the request within <cftry>/<cfcatch> is still suggested though.)
Here's an example requesting a non-existent website (404 Not Found) on Tomcat/Railo:

Related

BizTalk - Why does a suspended message appear in the console for a handled exception?

Here is an image of a common structure we have in a few of our BizTalk orchestrations:
So when we GET information from an API and the account doesn't exist, we terminate the orchestration. This works fine and I can see the orchestration doing this and terminating when it should, but what I don't understand is why do I see the suspended message from the GET in the console? Since the exception handling works, shouldn't this stop an error showing in the console?
As a way around this, I've considered using a pipeline component to check the response message, and if it contains what would be ignored, just return null in place of the message. Would this have the desired effect? I'm more interested as to why I see the suspended messages in the console.
Yes, this is a known issue with the WCF-WebHttp adapter, that has to do with the fact that it throws it back as a SOAP formatted error, but without setting the MessageType context property (see my blog post and look for Bug: BizTalk WCF-WebHttp adapter does not set the message type on error). So although the exception is thrown back at the Orchestration and can be handled there, the message is not as BizTalk does not know what type it is and it suspends.
A workaround we use is
To set Enable Routing for failed messages on the send port
To have a send port that subscribes to all the response messages from that send port using the BTS.SPName = xxxx filter, and send port sends it to a custom NULL adapter (throw the message away), and yes, your Orchestration will still get the good response as well as the exceptions.
Update the send port that handles routing errors from other send ports that we do want to go to our exception handing to exclude those send ports which we are handling via an Orchestration.

How can we send html tags in onesignal?

I need to send messages to clients using onesignal from my webservice based on vb.net. Those messages are sent between html tags like : <html><body>messagelinktext, but whenever I try to send it through one signal i got this error:
System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (pushMessage="message<a>link</a>text").
at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
at System.Web.HttpRequest.ValidateHttpValueCollection(HttpValueCollection collection, RequestValidationSource requestCollection)
at System.Web.HttpRequest.get_Form()
at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
Can someone suggest a solution to send html data through onesignal?
This error appears to be happening on your server side, and not from OneSignal.
Here is Microsoft's guide on this error message: https://msdn.microsoft.com/en-us/library/system.web.httprequestvalidationexception(v=vs.110).aspx
The Remarks section in the link above explains how to resolve this, to quote:
Constraining and validating user input is essential in a Web
application to prevent hacker attacks that rely on malicious input
strings. Cross-site scripting attacks are one example of such hacks.
Other types of malicious or undesired data can be passed in a request
through various forms of input. By limiting the kinds of data that is
passed at a low level in an application, you can prevent undesirable
events, even when programmers who are using your code do not put the
proper validation techniques in place.
Request validation detects
potentially malicious client input and throws this exception to abort
processing of the request. A request abort can indicate an attempt to
compromise the security of your application, such as a cross-site
scripting attack. It is strongly recommended that your application
explicitly check all input regarding request aborts. However, you can
disable request validation by setting the validateRequest attribute in
the directive to false, as shown in the following example: <%# Page validateRequest="false" %> To disable request validation for your
application, you must modify or create a Web.config file for your
application and set the validateRequest attribute of the pages section
to false, as shown in the following example:
<configuration>
<system.web>
<pages validateRequest="false" />
</system.web>
</configuration>
To disable request validation for all applications
on your server, you can make this modification to the Machine.config
file.

Intercept Http Endpoint Exception [Mule ESB]

I'am using Mule 3.3.0 CE and I would have a custom behaviour when an exception is thrown in an http outbound endpoint (i.e when I get a Connection Refused Exception or Connection Timeout Exception). Let's assume that I have this scenario: a SOAP Component and a Http Outbound Endpoint that realize together a cxf service client and let's assume that I can't use any exception strategy.
I would write an Interceptor which intercept the http exception (i.e Connection Refused) and in which I can write a custon behaviour (i.e send the message in a queue).
I need of an interceptor that intercept che http exception and no a SOAP Fault (that could be intercepted with a SOAPFaultInterceptor).
How can I realize this model?
Thank you all for any help
I found the solution. I used a custom interceptor ( component) just before the Http component and I extended the AbstractEnvelopeInterceptor that gives to me the possibility to work before, after and during the component is processing the message.
With this perspective, I implemented the last method. This method's sign contains a boolean value that is setted is an exception occurred. In this way I can leverage this method to handle any kind of exceptions that is related to Http Component.

WSO2 ESB catch transport exceptions (MessageBuilder)

When I read a message with a WSO2 ESB Proxy, I need to define a specific datatype and this is then applying a certain MessageBuilder (defined in the axis2.xml).
But when the MessageBuilder fails (i.e. I try to read a text file with the XMLBuilder) I get an exception in the console, but my "faultSequence" is not called. But I need to do a certain Error Handling in case of any read problem.
How can I catch Exceptions from the Transport Layer (MessageBuilder) in a Proxy?
As far as i understand , your requirement is to catch an Error in the Transport layer and handle that in the Application level (i.e : Mediation level). which means the layer above.
But i think it violates layered architecture of the messaging framework. You should catch the Exception at the Message Builder itself and throw an Axis Fault so that underlying synapse transport layer (in this case Axis2) will handle that error. (It will send a fault to the client.)
If we look at the TCP protocol stack that is the practice which is commonly used.
If you really want to filter this errors at mediation level. Catch that Error in the Message Builder and add a Message Context property or custom message and pass it as a successful message. And Do a filter in mediation level and handle.
But again that is ugly.
:)
--Charith
Have you defined onError attribute in your configuration?
<sequence name="main" onError="myFaultSequence">
You can have more information in this sample.

With ServiceStack, can I add a log reference all error responses?

I've implemented logging of all requests/responses using (in my AppHost.cs):
this.RequestFilters.Add(serviceLogFilter.LogRequest);
this.ResponseFilters.Add(serviceLogFilter.LogResponse);
During the logging of the request, I get the new ID from the logging table and put it into IHttpRequest.Items.
My question is: when an error occurs, like if the validation of the incoming data fails, or my business logic throws an Exception, is there a way I can customize the returned error to contain my log reference? Preferably by adding a JSON body to the error response. Alternatively, setting a custom HTTP header?
The idea is that my customer could give me a log reference if something unexcpected happens, and I would find his request and could easily reproduce the problem.
See this question on different ways to Handle exceptions from the old and New API.
To use the IHttpRequest.Items dictionary to pass data between request filters, services and response filters in the same request.
Also the InMemoryRollingRequestLogger implementation for the Request Logger plugin shows another way to be able to log all requests.