gl2: split error handling into seperate file.