check error variable before writing into *error. ALWAYS!