Added ability to set onErrorTarget and onErrorKey