Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 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 | #ifndef SHILL_ERROR_ |
| 6 | #define SHILL_ERROR_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include <base/basictypes.h> |
| 11 | |
| 12 | namespace DBus { |
| 13 | class Error; |
| 14 | } // namespace DBus |
| 15 | |
| 16 | namespace shill { |
| 17 | |
| 18 | class Error { |
| 19 | public: |
| 20 | enum Type { |
| 21 | kAlreadyExists, |
| 22 | kInProgress, |
| 23 | kInternalError, |
| 24 | kInvalidArguments, |
| 25 | kInvalidNetworkName, |
| 26 | kInvalidPassphrase, |
| 27 | kInvalidProperty, |
| 28 | kNotFound, |
| 29 | kNotSupported, |
| 30 | kPermissionDenied, |
| 31 | kPinError, |
| 32 | kNumErrors |
| 33 | }; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 34 | static const char * const kErrorNames[kNumErrors]; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 35 | |
| 36 | Error(Type type, const std::string& message); |
| 37 | virtual ~Error(); |
| 38 | |
| 39 | void Populate(Type type, const std::string& message); |
| 40 | |
| 41 | void ToDBusError(::DBus::Error *error); |
| 42 | |
| 43 | private: |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 44 | Type type_; |
| 45 | std::string message_; |
| 46 | |
| 47 | DISALLOW_COPY_AND_ASSIGN(Error); |
| 48 | }; |
| 49 | |
| 50 | } // namespace shill |
| 51 | |
| 52 | #endif // SHILL_ERROR_ |