Return meaningful error codes from functions.