David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 1 | // Copyright (c) 2013 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 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 5 | #ifndef UPDATE_ENGINE_ERROR_CODE_H_ |
| 6 | #define UPDATE_ENGINE_ERROR_CODE_H_ |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 7 | |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 8 | #include <ostream> // NOLINT(readability/streams) |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 9 | |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 10 | namespace chromeos_update_engine { |
| 11 | |
| 12 | // Action exit codes. |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 13 | enum class ErrorCode : int { |
| 14 | kSuccess = 0, |
| 15 | kError = 1, |
| 16 | kOmahaRequestError = 2, |
| 17 | kOmahaResponseHandlerError = 3, |
| 18 | kFilesystemCopierError = 4, |
| 19 | kPostinstallRunnerError = 5, |
| 20 | kPayloadMismatchedType = 6, |
| 21 | kInstallDeviceOpenError = 7, |
| 22 | kKernelDeviceOpenError = 8, |
| 23 | kDownloadTransferError = 9, |
| 24 | kPayloadHashMismatchError = 10, |
| 25 | kPayloadSizeMismatchError = 11, |
| 26 | kDownloadPayloadVerificationError = 12, |
| 27 | kDownloadNewPartitionInfoError = 13, |
| 28 | kDownloadWriteError = 14, |
| 29 | kNewRootfsVerificationError = 15, |
| 30 | kNewKernelVerificationError = 16, |
| 31 | kSignedDeltaPayloadExpectedError = 17, |
| 32 | kDownloadPayloadPubKeyVerificationError = 18, |
| 33 | kPostinstallBootedFromFirmwareB = 19, |
| 34 | kDownloadStateInitializationError = 20, |
| 35 | kDownloadInvalidMetadataMagicString = 21, |
| 36 | kDownloadSignatureMissingInManifest = 22, |
| 37 | kDownloadManifestParseError = 23, |
| 38 | kDownloadMetadataSignatureError = 24, |
| 39 | kDownloadMetadataSignatureVerificationError = 25, |
| 40 | kDownloadMetadataSignatureMismatch = 26, |
| 41 | kDownloadOperationHashVerificationError = 27, |
| 42 | kDownloadOperationExecutionError = 28, |
| 43 | kDownloadOperationHashMismatch = 29, |
| 44 | kOmahaRequestEmptyResponseError = 30, |
| 45 | kOmahaRequestXMLParseError = 31, |
| 46 | kDownloadInvalidMetadataSize = 32, |
| 47 | kDownloadInvalidMetadataSignature = 33, |
| 48 | kOmahaResponseInvalid = 34, |
| 49 | kOmahaUpdateIgnoredPerPolicy = 35, |
| 50 | kOmahaUpdateDeferredPerPolicy = 36, |
| 51 | kOmahaErrorInHTTPResponse = 37, |
| 52 | kDownloadOperationHashMissingError = 38, |
| 53 | kDownloadMetadataSignatureMissingError = 39, |
| 54 | kOmahaUpdateDeferredForBackoff = 40, |
| 55 | kPostinstallPowerwashError = 41, |
| 56 | kUpdateCanceledByChannelChange = 42, |
| 57 | kPostinstallFirmwareRONotUpdatable = 43, |
| 58 | kUnsupportedMajorPayloadVersion = 44, |
| 59 | kUnsupportedMinorPayloadVersion = 45, |
David Zeuthen | f3e2801 | 2014-08-26 18:23:52 -0400 | [diff] [blame] | 60 | kOmahaRequestXMLHasEntityDecl = 46, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 61 | |
Don Garrett | 4d03944 | 2013-10-28 18:40:06 -0700 | [diff] [blame] | 62 | // VERY IMPORTANT! When adding new error codes: |
| 63 | // |
| 64 | // 1) Update tools/metrics/histograms/histograms.xml in Chrome. |
| 65 | // |
| 66 | // 2) Update the assorted switch statements in update_engine which won't |
| 67 | // build until this case is added. |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 68 | |
| 69 | // Any code above this is sent to both Omaha and UMA as-is, except |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 70 | // kOmahaErrorInHTTPResponse (see error code 2000 for more details). |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 71 | // Codes/flags below this line is sent only to Omaha and not to UMA. |
| 72 | |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 73 | // kUmaReportedMax is not an error code per se, it's just the count |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 74 | // of the number of enums above. Add any new errors above this line if you |
| 75 | // want them to show up on UMA. Stuff below this line will not be sent to UMA |
| 76 | // but is used for other errors that are sent to Omaha. We don't assign any |
| 77 | // particular value for this enum so that it's just one more than the last |
| 78 | // one above and thus always represents the correct count of UMA metrics |
| 79 | // buckets, even when new enums are added above this line in future. See |
| 80 | // utils::SendErrorCodeToUma on how this enum is used. |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 81 | kUmaReportedMax, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 82 | |
| 83 | // use the 2xxx range to encode HTTP errors. These errors are available in |
| 84 | // Dremel with the individual granularity. But for UMA purposes, all these |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 85 | // errors are aggregated into one: kOmahaErrorInHTTPResponse. |
| 86 | kOmahaRequestHTTPResponseBase = 2000, // + HTTP response code |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 87 | |
| 88 | // TODO(jaysri): Move out all the bit masks into separate constants |
| 89 | // outside the enum as part of fixing bug 34369. |
| 90 | // Bit flags. Remember to update the mask below for new bits. |
| 91 | |
| 92 | // Set if boot mode not normal. |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 93 | // TODO(garnold) This is very debatable value to use, knowing that the |
| 94 | // underlying type is a signed int (often, 32-bit). However, at this point |
| 95 | // there are parts of the ecosystem that expect this to be a negative value, |
| 96 | // so we preserve this semantics. This should be reconsidered if/when we |
| 97 | // modify the implementation of ErrorCode into a properly encapsulated class. |
| 98 | kDevModeFlag = 1 << 31, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 99 | |
| 100 | // Set if resuming an interruped update. |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 101 | kResumedFlag = 1 << 30, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 102 | |
| 103 | // Set if using a dev/test image as opposed to an MP-signed image. |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 104 | kTestImageFlag = 1 << 29, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 105 | |
| 106 | // Set if using devserver or Omaha sandbox (using crosh autest). |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 107 | kTestOmahaUrlFlag = 1 << 28, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 108 | |
| 109 | // Mask that indicates bit positions that are used to indicate special flags |
| 110 | // that are embedded in the error code to provide additional context about |
| 111 | // the system in which the error was encountered. |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 112 | kSpecialFlags = (kDevModeFlag | kResumedFlag | kTestImageFlag | |
| 113 | kTestOmahaUrlFlag) |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 114 | }; |
| 115 | |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 116 | inline std::ostream& operator<<(std::ostream& os, ErrorCode val) { |
| 117 | return os << static_cast<int>(val); |
| 118 | } |
| 119 | |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 120 | } // namespace chromeos_update_engine |
| 121 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 122 | #endif // UPDATE_ENGINE_ERROR_CODE_H_ |