Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch errors from remote API #5

Open
MAH1987 opened this issue Jul 20, 2020 · 2 comments
Open

catch errors from remote API #5

MAH1987 opened this issue Jul 20, 2020 · 2 comments

Comments

@MAH1987
Copy link

MAH1987 commented Jul 20, 2020

Is it possible, when the connection failure intercept and give a feedback to users, that this searchpage has an error?

[20:40:01] [Server thread/INFO]: ADMIN issued server command: /headsinv search worms
[20:40:01] [Thread-76/INFO]: [com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl] Updating heads for: worms
[20:40:01] [Thread-76/ERROR]: [com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder] Got response with status code: 502 (Bad Gateway)
[20:40:01] [Thread-76/ERROR]: [com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder] For request: https://freshcoal.com/api.php?query=worms
[20:40:01] [Thread-76/ERROR]: [com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder] Request headers:
[20:40:01] [Thread-76/ERROR]: [com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder] Response headers:
 - connection: keep-alive
 - content-length: 181
 - content-type: text/html
 - date: Mon, 20 Jul 2020 18:42:58 GMT
 - server: nginx/1.4.6 (Ubuntu)
[20:40:01] [Thread-76/ERROR]: [com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder] Body:
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.4.6 (Ubuntu)</center>
</body>
</html>

[20:40:01] [Thread-76/WARN]: Exception in thread "Thread-76" feign.FeignException$BadGateway: [502 Bad Gateway] during [GET] to [https://freshcoal.com/api.php?query=worms] [FreshCoalClient#find(String)]: []
[20:40:01] [Thread-76/WARN]: 	at feign.FeignException.serverErrorStatus(FeignException.java:235)
[20:40:01] [Thread-76/WARN]: 	at feign.FeignException.errorStatus(FeignException.java:180)
[20:40:01] [Thread-76/WARN]: 	at feign.FeignException.errorStatus(FeignException.java:169)
[20:40:01] [Thread-76/WARN]: 	at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92)
[20:40:01] [Thread-76/WARN]: 	at com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder.decode(StatusCodeHandlingErrorDecoder.java:49)
[20:40:01] [Thread-76/WARN]: 	at feign.AsyncResponseHandler.handleResponse(AsyncResponseHandler.java:96)
[20:40:01] [Thread-76/WARN]: 	at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138)
[20:40:01] [Thread-76/WARN]: 	at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89)
[20:40:01] [Thread-76/WARN]: 	at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100)
[20:40:01] [Thread-76/WARN]: 	at com.sun.proxy.$Proxy154.find(Unknown Source)
[20:40:01] [Thread-76/WARN]: 	at com.github.cc007.headsplugin.integration.daos.heads.FreshCoalDao.getHeads(FreshCoalDao.java:66)
[20:40:01] [Thread-76/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl.lambda$requestHeads$1(HeadSearcherImpl.java:137)
[20:40:01] [Thread-76/WARN]: 	at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1321)
[20:40:01] [Thread-76/WARN]: 	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
[20:40:01] [Thread-76/WARN]: 	at java.util.Iterator.forEachRemaining(Iterator.java:116)
[20:40:01] [Thread-76/WARN]: 	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
[20:40:01] [Thread-76/WARN]: 	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
[20:40:01] [Thread-76/WARN]: 	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
[20:40:01] [Thread-76/WARN]: 	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
[20:40:01] [Thread-76/WARN]: 	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[20:40:01] [Thread-76/WARN]: 	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
[20:40:01] [Thread-76/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl.requestHeads(HeadSearcherImpl.java:135)
[20:40:01] [Thread-76/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl.updateSearch(HeadSearcherImpl.java:103)
[20:40:01] [Thread-76/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl.getHeads(HeadSearcherImpl.java:70)
[20:40:01] [Thread-76/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl$$FastClassBySpringCGLIB$$2807e26f.invoke(<generated>)
[20:40:01] [Thread-76/WARN]: 	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
[20:40:01] [Thread-76/WARN]: 	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
[20:40:01] [Thread-76/WARN]: 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
[20:40:01] [Thread-76/WARN]: 	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
[20:40:01] [Thread-76/WARN]: 	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
[20:40:01] [Thread-76/WARN]: 	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
[20:40:01] [Thread-76/WARN]: 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[20:40:01] [Thread-76/WARN]: 	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
[20:40:01] [Thread-76/WARN]: 	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
[20:40:01] [Thread-76/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl$$EnhancerBySpringCGLIB$$9777e985.getHeads(<generated>)
[20:40:01] [Thread-76/WARN]: 	at com.github.cc007.headsinventory.search.HeadsSearch.lambda$search$2(HeadsSearch.java:152)
[20:40:01] [Thread-76/WARN]: 	at java.lang.Thread.run(Thread.java:748)
[20:40:49] [Server thread/INFO]: ADMIN issued server command: /headsinv search worm
[20:40:49] [Thread-77/INFO]: [com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl] Updating heads for: worm
[20:40:49] [Thread-77/ERROR]: [com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder] Got response with status code: 502 (Bad Gateway)
[20:40:49] [Thread-77/ERROR]: [com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder] For request: https://freshcoal.com/api.php?query=worm
[20:40:49] [Thread-77/ERROR]: [com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder] Request headers:
[20:40:49] [Thread-77/ERROR]: [com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder] Response headers:
 - connection: keep-alive
 - content-length: 181
 - content-type: text/html
 - date: Mon, 20 Jul 2020 18:43:46 GMT
 - server: nginx/1.4.6 (Ubuntu)
[20:40:49] [Thread-77/ERROR]: [com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder] Body:
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.4.6 (Ubuntu)</center>
</body>
</html>

[20:40:49] [Thread-77/WARN]: Exception in thread "Thread-77" feign.FeignException$BadGateway: [502 Bad Gateway] during [GET] to [https://freshcoal.com/api.php?query=worm] [FreshCoalClient#find(String)]: []
[20:40:49] [Thread-77/WARN]: 	at feign.FeignException.serverErrorStatus(FeignException.java:235)
[20:40:49] [Thread-77/WARN]: 	at feign.FeignException.errorStatus(FeignException.java:180)
[20:40:49] [Thread-77/WARN]: 	at feign.FeignException.errorStatus(FeignException.java:169)
[20:40:49] [Thread-77/WARN]: 	at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92)
[20:40:49] [Thread-77/WARN]: 	at com.github.cc007.headsplugin.config.feign.statuscodes.StatusCodeHandlingErrorDecoder.decode(StatusCodeHandlingErrorDecoder.java:49)
[20:40:49] [Thread-77/WARN]: 	at feign.AsyncResponseHandler.handleResponse(AsyncResponseHandler.java:96)
[20:40:49] [Thread-77/WARN]: 	at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138)
[20:40:49] [Thread-77/WARN]: 	at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89)
[20:40:49] [Thread-77/WARN]: 	at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100)
[20:40:49] [Thread-77/WARN]: 	at com.sun.proxy.$Proxy154.find(Unknown Source)
[20:40:49] [Thread-77/WARN]: 	at com.github.cc007.headsplugin.integration.daos.heads.FreshCoalDao.getHeads(FreshCoalDao.java:66)
[20:40:49] [Thread-77/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl.lambda$requestHeads$1(HeadSearcherImpl.java:137)
[20:40:49] [Thread-77/WARN]: 	at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1321)
[20:40:49] [Thread-77/WARN]: 	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
[20:40:49] [Thread-77/WARN]: 	at java.util.Iterator.forEachRemaining(Iterator.java:116)
[20:40:49] [Thread-77/WARN]: 	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
[20:40:49] [Thread-77/WARN]: 	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
[20:40:49] [Thread-77/WARN]: 	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
[20:40:49] [Thread-77/WARN]: 	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
[20:40:49] [Thread-77/WARN]: 	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[20:40:49] [Thread-77/WARN]: 	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
[20:40:49] [Thread-77/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl.requestHeads(HeadSearcherImpl.java:135)
[20:40:49] [Thread-77/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl.updateSearch(HeadSearcherImpl.java:103)
[20:40:49] [Thread-77/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl.getHeads(HeadSearcherImpl.java:70)
[20:40:49] [Thread-77/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl$$FastClassBySpringCGLIB$$2807e26f.invoke(<generated>)
[20:40:49] [Thread-77/WARN]: 	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
[20:40:49] [Thread-77/WARN]: 	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
[20:40:49] [Thread-77/WARN]: 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
[20:40:49] [Thread-77/WARN]: 	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
[20:40:49] [Thread-77/WARN]: 	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
[20:40:49] [Thread-77/WARN]: 	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
[20:40:49] [Thread-77/WARN]: 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[20:40:49] [Thread-77/WARN]: 	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
[20:40:49] [Thread-77/WARN]: 	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
[20:40:49] [Thread-77/WARN]: 	at com.github.cc007.headsplugin.business.services.heads.HeadSearcherImpl$$EnhancerBySpringCGLIB$$9777e985.getHeads(<generated>)
[20:40:49] [Thread-77/WARN]: 	at com.github.cc007.headsinventory.search.HeadsSearch.lambda$search$2(HeadsSearch.java:152)
[20:40:49] [Thread-77/WARN]: 	at java.lang.Thread.run(Thread.java:748)

@CC007
Copy link
Owner

CC007 commented Jul 20, 2020

I'll see what I can do. Btw, if the search on Freshcoal fails, that doesn't mean that you don't get any heads from your search. It will still include all heads mineskin.org and from categories that contain the search term.

Note: the error you see is based on an old version of HeadsPluginAPI. Today I released HeadsPluginAPI 2.0.5, which would only log Got response with status code: 502 (Bad Gateway) and added a warning if no heads were found for a search or category update.

@MAH1987
Copy link
Author

MAH1987 commented Jul 20, 2020

I'll see what I can do. Btw, if the search on Freshcoal fails, that doesn't mean that you don't get any heads from your search. It will still include all heads mineskin.org and from categories that contain the search term.

Note: the error you see is based on an old version of HeadsPluginAPI. Today I released HeadsPluginAPI 2.0.5, which would only log Got response with status code: 502 (Bad Gateway) and added a warning if no heads were found for a search or category update.

Nice! I will try the new version tomorow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants