blob: 3371da42c0f74581fb9503c199ae5734a7ee1cc2 [file] [log] [blame]
Alex Deymo44666f92014-07-22 20:29:24 -07001// Copyright 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "update_engine/glib_utils.h"
6
7#include <base/strings/stringprintf.h>
8
9using std::string;
10
11namespace chromeos_update_engine {
12namespace utils {
13
14string GetAndFreeGError(GError** error) {
15 if (!*error) {
16 return "Unknown GLib error.";
17 }
18 string message =
19 base::StringPrintf("GError(%d): %s",
20 (*error)->code,
21 (*error)->message ? (*error)->message : "(unknown)");
22 g_error_free(*error);
Alex Vakulenko88b591f2014-08-28 16:48:57 -070023 *error = nullptr;
Alex Deymo44666f92014-07-22 20:29:24 -070024 return message;
25}
26
27} // namespace utils
28} // namespace chromeos_update_engine