The common LSI SAS/SATA adapters report an error code when an IO fails by the HBA itself. These error codes by their nature are cryptic but do carry some useful information if one can decode them. For example you can refer to my post on LSI LogInfo 0x31080000. Unfortunately LSI are not detailing publicly how to decode these error codes and what they mean, the only open information is what can be found in Linux kernel drivers and from that I built a tool to decode the LSI LogInfo.
The decoding is still pretty cryptic and looks like this:
./lsi_decode_loginfo 0x31080000 Type: 30000000h SAS Origin: 01000000h PL Code: 00080000h PL_LOGINFO_CODE_SATA_NCQ_FAIL_ALL_CMDS_AFTR_ERR
But it is far better than the numeric code itself.
You can also see all error codes decoded at LSI LogInfo Decodes