A panel of appellate court justices in Santa Ana have ruled that lower court judges erred when they took primary custody of his son away from a Camp Pendleton-based Marine while he was on a tour of duty in Afghanistan, according to records obtained this week.