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 | |
Alex Deymo | 759c275 | 2014-03-17 21:09:36 -0700 | [diff] [blame] | 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_ |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 7 | |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame^] | 8 | #include <ostream> |
| 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 | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 60 | |
Don Garrett | 4d03944 | 2013-10-28 18:40:06 -0700 | [diff] [blame] | 61 | // VERY IMPORTANT! When adding new error codes: |
| 62 | // |
| 63 | // 1) Update tools/metrics/histograms/histograms.xml in Chrome. |
| 64 | // |
| 65 | // 2) Update the assorted switch statements in update_engine which won't |
| 66 | // build until this case is added. |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 67 | |
| 68 | // 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^] | 69 | // kOmahaErrorInHTTPResponse (see error code 2000 for more details). |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 70 | // Codes/flags below this line is sent only to Omaha and not to UMA. |
| 71 | |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame^] | 72 | // 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] | 73 | // of the number of enums above. Add any new errors above this line if you |
| 74 | // want them to show up on UMA. Stuff below this line will not be sent to UMA |
| 75 | // but is used for other errors that are sent to Omaha. We don't assign any |
| 76 | // particular value for this enum so that it's just one more than the last |
| 77 | // one above and thus always represents the correct count of UMA metrics |
| 78 | // buckets, even when new enums are added above this line in future. See |
| 79 | // utils::SendErrorCodeToUma on how this enum is used. |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame^] | 80 | kUmaReportedMax, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 81 | |
| 82 | // use the 2xxx range to encode HTTP errors. These errors are available in |
| 83 | // Dremel with the individual granularity. But for UMA purposes, all these |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame^] | 84 | // errors are aggregated into one: kOmahaErrorInHTTPResponse. |
| 85 | kOmahaRequestHTTPResponseBase = 2000, // + HTTP response code |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 86 | |
| 87 | // TODO(jaysri): Move out all the bit masks into separate constants |
| 88 | // outside the enum as part of fixing bug 34369. |
| 89 | // Bit flags. Remember to update the mask below for new bits. |
| 90 | |
| 91 | // Set if boot mode not normal. |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame^] | 92 | // TODO(garnold) This is very debatable value to use, knowing that the |
| 93 | // underlying type is a signed int (often, 32-bit). However, at this point |
| 94 | // there are parts of the ecosystem that expect this to be a negative value, |
| 95 | // so we preserve this semantics. This should be reconsidered if/when we |
| 96 | // modify the implementation of ErrorCode into a properly encapsulated class. |
| 97 | kDevModeFlag = 1 << 31, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 98 | |
| 99 | // Set if resuming an interruped update. |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame^] | 100 | kResumedFlag = 1 << 30, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 101 | |
| 102 | // 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^] | 103 | kTestImageFlag = 1 << 29, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 104 | |
| 105 | // Set if using devserver or Omaha sandbox (using crosh autest). |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame^] | 106 | kTestOmahaUrlFlag = 1 << 28, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 107 | |
| 108 | // Mask that indicates bit positions that are used to indicate special flags |
| 109 | // that are embedded in the error code to provide additional context about |
| 110 | // the system in which the error was encountered. |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame^] | 111 | kSpecialFlags = (kDevModeFlag | kResumedFlag | kTestImageFlag | |
| 112 | kTestOmahaUrlFlag) |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 113 | }; |
| 114 | |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame^] | 115 | inline std::ostream& operator<<(std::ostream& os, ErrorCode val) { |
| 116 | return os << static_cast<int>(val); |
| 117 | } |
| 118 | |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 119 | } // namespace chromeos_update_engine |
| 120 | |
Alex Deymo | 759c275 | 2014-03-17 21:09:36 -0700 | [diff] [blame] | 121 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_ |