You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cloud <cl...@domolo.com> on 2015/06/04 03:59:31 UTC
How to avoid direct error message or exception print out put on
screen ?
hi all,
I am using camel for http proxy , such as :
use proxy url
FROM http://127.0.0.1:8199/test?chunked=false
TO http://192.7.0.54:8081/?bridgeEndpoint=true
In debug stage , so ,I shutdown the server's port : 192.7.0.54:8081 .
If I visit url http://127.0.0.1:8199/test?chunked=false , the exception
directly output on screen .
How can I catch this exception , and with my replace to a more friendly
message instead ?
org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing
request: Connection refused
Jun 04, 2015 9:34:50 AM org.apache.commons.httpclient.HttpMethodDirector
executeWithRetry
ERROR org.apache.camel.processor.DefaultErrorHandler -
Failed delivery for (MessageId: ID-acsdev9-60320-1433381616150-0-2 on
ExchangeId: ID-acsdev9-60320-1433381616150-0-1).
Exhausted after delivery attempt: 1 caught: java.net.ConnectException:
Connection refused
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor
Elapsed (ms)
[ProxyRepo ] [ProxyRepo ] [http://127.0.0.1:8199/test?chunked=false
] [ 45]
[ProxyRepo ] [to1 ] [http://172.27.0.54:8081/?bridgeEndpoint=true
] [ 42]
Exchange
-----------------------------------------------
Exchange[
Id ID-acsdev9-60320-1433381616150-0-1
ExchangePattern InOut
Headers {Accept=text/html,... ... ... ,
CamelHttpServletResponse=HTTP/1.1 200
}
BodyType null
Body [Body is null]
]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-avoid-direct-error-message-or-exception-print-out-put-on-screen-tp5767850.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to avoid direct error message or exception print out put on
screen ?
Posted by Claus Ibsen <cl...@gmail.com>.
You can use Camel's error handler
http://camel.apache.org/error-handling-in-camel.html
For example using onException handled (true) and then create some
custom error response message to return such as setting a http status
code to 404 etc
On Thu, Jun 4, 2015 at 3:59 AM, cloud <cl...@domolo.com> wrote:
> hi all,
>
> I am using camel for http proxy , such as :
>
> use proxy url
> FROM http://127.0.0.1:8199/test?chunked=false
> TO http://192.7.0.54:8081/?bridgeEndpoint=true
>
> In debug stage , so ,I shutdown the server's port : 192.7.0.54:8081 .
> If I visit url http://127.0.0.1:8199/test?chunked=false , the exception
> directly output on screen .
>
> How can I catch this exception , and with my replace to a more friendly
> message instead ?
>
>
>
>
> org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
> INFO: I/O exception (java.net.ConnectException) caught when processing
> request: Connection refused
> Jun 04, 2015 9:34:50 AM org.apache.commons.httpclient.HttpMethodDirector
> executeWithRetry
>
>
> ERROR org.apache.camel.processor.DefaultErrorHandler -
> Failed delivery for (MessageId: ID-acsdev9-60320-1433381616150-0-2 on
> ExchangeId: ID-acsdev9-60320-1433381616150-0-1).
> Exhausted after delivery attempt: 1 caught: java.net.ConnectException:
> Connection refused
>
>
> Message History
> ---------------------------------------------------------------------------------------------------------------------------------------
> RouteId ProcessorId Processor
> Elapsed (ms)
> [ProxyRepo ] [ProxyRepo ] [http://127.0.0.1:8199/test?chunked=false
> ] [ 45]
> [ProxyRepo ] [to1 ] [http://172.27.0.54:8081/?bridgeEndpoint=true
> ] [ 42]
>
> Exchange
> -----------------------------------------------
> Exchange[
> Id ID-acsdev9-60320-1433381616150-0-1
> ExchangePattern InOut
> Headers {Accept=text/html,... ... ... ,
> CamelHttpServletResponse=HTTP/1.1 200
> }
> BodyType null
> Body [Body is null]
> ]
>
> Stacktrace
> ---------------------------------------------------------------------------------------------------------------------------------------
> java.net.ConnectException: Connection refused
> at java.net.PlainSocketImpl.socketConnect(Native Method)
> at
> java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-avoid-direct-error-message-or-exception-print-out-put-on-screen-tp5767850.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/