[M120 Migration][VD] Fix url crash in RequestCertificateConfirm
[platform/framework/web/chromium-efl.git] / dbus / error.h
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.
4
5 #ifndef DBUS_ERROR_H_
6 #define DBUS_ERROR_H_
7
8 #include <string>
9
10 #include "dbus/dbus_export.h"
11
12 namespace dbus {
13
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
17 // from libdbus.
18 class CHROME_DBUS_EXPORT Error {
19  public:
20   // Creates an invalid error.
21   Error();
22
23   // Creates an error instance with the given name and the message.
24   Error(std::string name, std::string message);
25   Error(Error&& other);
26   Error& operator=(Error&& other);
27   ~Error();
28
29   // Returns true if the error is valid one.
30   bool IsValid() const { return !name_.empty(); }
31
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_; }
38
39   // Returns (human readable) error message attached to D-Bus error.
40   const std::string& message() const { return message_; }
41
42  private:
43   std::string name_;
44   std::string message_;
45 };
46
47 }  // namespace dbus
48
49 #endif  // DBUS_ERROR_H_