Revert "merged branch Tobion/flattenexception (PR #9111)"

This reverts commit 53b2048c4cf0b62251de3906c4665ff5adf31ec4, reversing
changes made to c60a8e962b03b6476db70c962a839b98127b1743.