Return if there's an error but only log if debug flag is set