blob: 6a47784b342da4480cb73e9a3b1ef5443d01fb3d [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
Gilad Arnoldcf175a02014-07-10 16:48:47 -07005#ifndef UPDATE_ENGINE_ERROR_CODE_H_
6#define UPDATE_ENGINE_ERROR_CODE_H_
David Zeuthena99981f2013-04-29 13:42:47 -07007
Alex Vakulenkod2779df2014-06-16 13:19:00 -07008#include <ostream> // NOLINT(readability/streams)
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -07009
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 Zeuthenf3e28012014-08-26 18:23:52 -040060 kOmahaRequestXMLHasEntityDecl = 46,
David Zeuthena99981f2013-04-29 13:42:47 -070061
Don Garrett4d039442013-10-28 18:40:06 -070062 // 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 Zeuthena99981f2013-04-29 13:42:47 -070068
69 // Any code above this is sent to both Omaha and UMA as-is, except
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070070 // kOmahaErrorInHTTPResponse (see error code 2000 for more details).
David Zeuthena99981f2013-04-29 13:42:47 -070071 // Codes/flags below this line is sent only to Omaha and not to UMA.
72
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070073 // kUmaReportedMax is not an error code per se, it's just the count
David Zeuthena99981f2013-04-29 13:42:47 -070074 // 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 Arnoldd1c4d2d2014-06-05 14:07:53 -070081 kUmaReportedMax,
David Zeuthena99981f2013-04-29 13:42:47 -070082
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 Arnoldd1c4d2d2014-06-05 14:07:53 -070085 // errors are aggregated into one: kOmahaErrorInHTTPResponse.
86 kOmahaRequestHTTPResponseBase = 2000, // + HTTP response code
David Zeuthena99981f2013-04-29 13:42:47 -070087
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 Arnoldd1c4d2d2014-06-05 14:07:53 -070093 // 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 Zeuthena99981f2013-04-29 13:42:47 -070099
100 // Set if resuming an interruped update.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700101 kResumedFlag = 1 << 30,
David Zeuthena99981f2013-04-29 13:42:47 -0700102
103 // Set if using a dev/test image as opposed to an MP-signed image.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700104 kTestImageFlag = 1 << 29,
David Zeuthena99981f2013-04-29 13:42:47 -0700105
106 // Set if using devserver or Omaha sandbox (using crosh autest).
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700107 kTestOmahaUrlFlag = 1 << 28,
David Zeuthena99981f2013-04-29 13:42:47 -0700108
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 Arnoldd1c4d2d2014-06-05 14:07:53 -0700112 kSpecialFlags = (kDevModeFlag | kResumedFlag | kTestImageFlag |
113 kTestOmahaUrlFlag)
David Zeuthena99981f2013-04-29 13:42:47 -0700114};
115
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700116inline std::ostream& operator<<(std::ostream& os, ErrorCode val) {
117 return os << static_cast<int>(val);
118}
119
David Zeuthena99981f2013-04-29 13:42:47 -0700120} // namespace chromeos_update_engine
121
Gilad Arnoldcf175a02014-07-10 16:48:47 -0700122#endif // UPDATE_ENGINE_ERROR_CODE_H_