blob: 5f3a2cb224d28d0b802d3f37cdea0d32cbef7044 [file] [log] [blame]
David Zeuthena99981f2013-04-29 13:42:47 -07001// 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 Deymo759c2752014-03-17 21:09:36 -07005#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_
David Zeuthena99981f2013-04-29 13:42:47 -07007
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -07008#include <ostream>
9
David Zeuthena99981f2013-04-29 13:42:47 -070010namespace chromeos_update_engine {
11
12// Action exit codes.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070013enum 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 Zeuthena99981f2013-04-29 13:42:47 -070060
Don Garrett4d039442013-10-28 18:40:06 -070061 // 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 Zeuthena99981f2013-04-29 13:42:47 -070067
68 // Any code above this is sent to both Omaha and UMA as-is, except
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070069 // kOmahaErrorInHTTPResponse (see error code 2000 for more details).
David Zeuthena99981f2013-04-29 13:42:47 -070070 // Codes/flags below this line is sent only to Omaha and not to UMA.
71
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070072 // kUmaReportedMax is not an error code per se, it's just the count
David Zeuthena99981f2013-04-29 13:42:47 -070073 // 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 Arnoldd1c4d2d2014-06-05 14:07:53 -070080 kUmaReportedMax,
David Zeuthena99981f2013-04-29 13:42:47 -070081
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 Arnoldd1c4d2d2014-06-05 14:07:53 -070084 // errors are aggregated into one: kOmahaErrorInHTTPResponse.
85 kOmahaRequestHTTPResponseBase = 2000, // + HTTP response code
David Zeuthena99981f2013-04-29 13:42:47 -070086
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 Arnoldd1c4d2d2014-06-05 14:07:53 -070092 // 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 Zeuthena99981f2013-04-29 13:42:47 -070098
99 // Set if resuming an interruped update.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700100 kResumedFlag = 1 << 30,
David Zeuthena99981f2013-04-29 13:42:47 -0700101
102 // Set if using a dev/test image as opposed to an MP-signed image.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700103 kTestImageFlag = 1 << 29,
David Zeuthena99981f2013-04-29 13:42:47 -0700104
105 // Set if using devserver or Omaha sandbox (using crosh autest).
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700106 kTestOmahaUrlFlag = 1 << 28,
David Zeuthena99981f2013-04-29 13:42:47 -0700107
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 Arnoldd1c4d2d2014-06-05 14:07:53 -0700111 kSpecialFlags = (kDevModeFlag | kResumedFlag | kTestImageFlag |
112 kTestOmahaUrlFlag)
David Zeuthena99981f2013-04-29 13:42:47 -0700113};
114
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700115inline std::ostream& operator<<(std::ostream& os, ErrorCode val) {
116 return os << static_cast<int>(val);
117}
118
David Zeuthena99981f2013-04-29 13:42:47 -0700119} // namespace chromeos_update_engine
120
Alex Deymo759c2752014-03-17 21:09:36 -0700121#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_