1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
10 #include "dbus/dbus_export.h"
14 // Represents D-Bus related errors.
15 // This carries error info retrieved from libdbus. Some APIs under dbus/
16 // may return empty Error instance to represent the API failed, but not
18 class CHROME_DBUS_EXPORT Error {
20 // Creates an invalid error.
23 // Creates an error instance with the given name and the message.
24 Error(std::string name, std::string message);
26 Error& operator=(Error&& other);
29 // Returns true if the error is valid one.
30 bool IsValid() const { return !name_.empty(); }
32 // Returns the name of the D-Bus error.
33 // Please see also "Error names" in
34 // https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names
35 // Specifically, valid name must have two components connected by '.', so this
36 // class uses empty name to represent invalid error instance.
37 const std::string& name() const { return name_; }
39 // Returns (human readable) error message attached to D-Bus error.
40 const std::string& message() const { return message_; }
49 #endif // DBUS_ERROR_H_