blob: 523a16fa1946ef1b857569a71c485db366cf1059 [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);
23 *error = NULL;
24 return message;
25}
26
27} // namespace utils
28} // namespace chromeos_update_engine