csv import fails without throwing an error
Encapsulate the LOAD in a Stored Procedure.  In there, capture the error and expose it to your script.

However, if LOAD DATA is not allowed in a Stored Proc, then you really need to write application code, not depend on on-line shell scripts.