return the proper error code