add custom flattenError option