Return err as undefined if no errors instead of empty object