add custom flattenError option
Merge pull request #7 from dominictarr/custom-flatten

add custom flattenError option