The code in question:
One suggestion has been that this can be cleaned up with the use of the errs library. Others have suggested that we should be able to handle the errors well before this function. Either way, decreasing the size and complexity of this function is a noble goal.
closing as #380 is a dup but has better info