[HttpKernel] fix usage of deprecated FlattenException
merged branch Tobion/flattenexception (PR #9111)

This PR was merged into the 2.3 branch.

Discussion
----------

[HttpKernel] fix usage of deprecated FlattenException

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #9108
| License       | MIT

Commits
-------

8bad61d [HttpKernel] fix usage of deprecated FlattenException