The Scottish Information Commissioner “erred in law” when he ordered ministers to disclose exempted material relating to the so-called Salmond files, a court has ruled.