Implementation of kdGetError/kdSetError