Fix bug, move error_msg assignment to inside of if(err) {} statement to avoid throwing a null error on err.msg lookup.