FlattenException from the HttpKernel is deprecated, removed type hint and manually checking the exception type