replace g_error_free with g_clear_error to null check internally