A fun one is: “throwing an error”, which can be translated in “lanciare (launch) un errore” or “tornare (return) un errore” or “causare (cause) un errore”.
I don't understand what's you problem with "lanciare". In C++ you have the couple "throw" and "catch", like "you throw the ball and I catch it". In Italian that is perfectly translated with "tu lanci la palla e io la prendo". What's the problem with that?
"return" in this context is "restituire", so "restituire (return) un errore" .
tornare is probably more likely unless you caused the error on purpose.
I would not use that: a common programming idiom is that of "returning an error code", and "ritornare un errore" may be confused with this. As in "return error;" where "error" is some error code, against "throw error;" where "error" is whatever exception class.