This should make sure these errors are synchronized with that from controller events HS_DESC HS_DESC_CONTENT HSFETCH HSPOST and other semantics and logging. I submitted a bunch of bugs and enhance on HS* controller command and event failures that can be trac searched and integrated with this. Some may have been prematurely closed. There have also been past talk about SOCKS5 on the list related to returning of some more errors codes via SOCKS5.
Update also https://gitweb.torproject.org/torspec.git/tree/socks-extensions.txt