If `LogAllExceptionsFilter` needs to log the curre...
# http4k
d
If
LogAllExceptionsFilter
needs to log the current user which is added by
AuthenticationFilter
, then how do you make sure exceptions thrown by
AuthenticationFilter
are handled properly? I mean if
AuthenticationFilter
comes first, its exceptions are not handled by
LogAllExceptionsFilter
. If
LogAllExceptionsFilter
comes first, it won’t have the current user.
d
Would a request context work here?
d
Yes context will work. I was wondering if there is another pattern. The problem with request context is that it has to come before LogAllExpections because context lens is not optional. And if the context is only used for auth, there are two filters required for auth 🤔
Also with Loom potentially switching threads, RequestContext.objects should probably be thread safe 🙈
d
AuthenticationFilter isn't a standard http4k filter is it
d
No, it’s a custom auth filter.
d
We generally use a CatchAll or equivalent only for last-effort catching and use results for everything else
Are you depending on the exception to be thrown for some reason?
d
If CatchAll wanted to log user it will have to come after auth 🙃 But how to make sure auth unexpected failure is logged in the same way as CatchAll does.
No, don’t care about exceptions. It’s about how to log user in the last resort filter.