Since we using RETURNING id for the insert routine, if a record fails to insert correctly the error returned is "expected 1 record but got 0" which isn't always the most descriptive error message. It would be better if we could surface the underlying issue like a constraint violation or something.