Stream: hapi
Topic: Throws Exception
Luan Garrido (Mar 04 2020 at 20:30):
Hello,
Whats is the proper way to throw an Exception from SERVER_INCOMING_REQUEST_POST_PROCESSED?
It only has ca.uhn.fhir.rest.server.exceptions.AuthenticationException throwable.
I need to throw a bad exception (Http status 400)
Thanks
James Agnew (Mar 04 2020 at 20:45):
You should be able to throw an InvalidRequestException from in there I believe
Luan Garrido (Mar 04 2020 at 20:47):
Thanks @James Agnew, but I can not use it.
The method demans throws an AuthenticationException
James Agnew (Mar 04 2020 at 21:24):
I'm not sure I follow. What happens if you throw InvalidRequestException?
Luan Garrido (Mar 04 2020 at 21:50):
I cannot throw new InvalidRequestException() and I can not modify the throws on method
See the image bellow:
James Agnew (Mar 05 2020 at 02:49):
InvalidRequestException is an unchecked exceptionm, so there's no compile-time reason you can't throw it anywhere. It doesn't have a no-arg constructor though, which is probably why eclipse is complaining there.
Also- you don't need to implement IServerInterceptor any longer- that is the old way of writing interceptors. It might be worth having a look at the docs for the new framework, which no longer relies on interfaces: https://hapifhir.io/hapi-fhir/docs/interceptors/
Luan Garrido (Mar 05 2020 at 13:48):
Hi @James Agnew
Using @Hook and Pointcut worked.
Thanks my friend =)
James Agnew (Mar 05 2020 at 14:49):
woohoo!
Last updated: Apr 12 2022 at 19:14 UTC