blob: 417e585e4858f848be6225660f9f8b2f13e2dc86 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2013 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
David Zeuthena99981f2013-04-29 13:42:47 -070016
Gilad Arnoldcf175a02014-07-10 16:48:47 -070017#ifndef UPDATE_ENGINE_ERROR_CODE_H_
18#define UPDATE_ENGINE_ERROR_CODE_H_
David Zeuthena99981f2013-04-29 13:42:47 -070019
Alex Vakulenkod2779df2014-06-16 13:19:00 -070020#include <ostream> // NOLINT(readability/streams)
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070021
David Zeuthena99981f2013-04-29 13:42:47 -070022namespace chromeos_update_engine {
23
24// Action exit codes.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070025enum class ErrorCode : int {
26 kSuccess = 0,
27 kError = 1,
28 kOmahaRequestError = 2,
29 kOmahaResponseHandlerError = 3,
30 kFilesystemCopierError = 4,
31 kPostinstallRunnerError = 5,
32 kPayloadMismatchedType = 6,
33 kInstallDeviceOpenError = 7,
34 kKernelDeviceOpenError = 8,
35 kDownloadTransferError = 9,
36 kPayloadHashMismatchError = 10,
37 kPayloadSizeMismatchError = 11,
38 kDownloadPayloadVerificationError = 12,
39 kDownloadNewPartitionInfoError = 13,
40 kDownloadWriteError = 14,
41 kNewRootfsVerificationError = 15,
42 kNewKernelVerificationError = 16,
43 kSignedDeltaPayloadExpectedError = 17,
44 kDownloadPayloadPubKeyVerificationError = 18,
45 kPostinstallBootedFromFirmwareB = 19,
46 kDownloadStateInitializationError = 20,
47 kDownloadInvalidMetadataMagicString = 21,
48 kDownloadSignatureMissingInManifest = 22,
49 kDownloadManifestParseError = 23,
50 kDownloadMetadataSignatureError = 24,
51 kDownloadMetadataSignatureVerificationError = 25,
52 kDownloadMetadataSignatureMismatch = 26,
53 kDownloadOperationHashVerificationError = 27,
54 kDownloadOperationExecutionError = 28,
55 kDownloadOperationHashMismatch = 29,
56 kOmahaRequestEmptyResponseError = 30,
57 kOmahaRequestXMLParseError = 31,
58 kDownloadInvalidMetadataSize = 32,
59 kDownloadInvalidMetadataSignature = 33,
60 kOmahaResponseInvalid = 34,
61 kOmahaUpdateIgnoredPerPolicy = 35,
62 kOmahaUpdateDeferredPerPolicy = 36,
63 kOmahaErrorInHTTPResponse = 37,
64 kDownloadOperationHashMissingError = 38,
65 kDownloadMetadataSignatureMissingError = 39,
66 kOmahaUpdateDeferredForBackoff = 40,
67 kPostinstallPowerwashError = 41,
68 kUpdateCanceledByChannelChange = 42,
69 kPostinstallFirmwareRONotUpdatable = 43,
70 kUnsupportedMajorPayloadVersion = 44,
71 kUnsupportedMinorPayloadVersion = 45,
David Zeuthenf3e28012014-08-26 18:23:52 -040072 kOmahaRequestXMLHasEntityDecl = 46,
Allie Woodeb9e6d82015-04-17 13:55:30 -070073 kFilesystemVerifierError = 47,
David Zeuthena99981f2013-04-29 13:42:47 -070074
Don Garrett4d039442013-10-28 18:40:06 -070075 // VERY IMPORTANT! When adding new error codes:
76 //
77 // 1) Update tools/metrics/histograms/histograms.xml in Chrome.
78 //
79 // 2) Update the assorted switch statements in update_engine which won't
80 // build until this case is added.
David Zeuthena99981f2013-04-29 13:42:47 -070081
82 // Any code above this is sent to both Omaha and UMA as-is, except
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070083 // kOmahaErrorInHTTPResponse (see error code 2000 for more details).
David Zeuthena99981f2013-04-29 13:42:47 -070084 // Codes/flags below this line is sent only to Omaha and not to UMA.
85
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070086 // kUmaReportedMax is not an error code per se, it's just the count
David Zeuthena99981f2013-04-29 13:42:47 -070087 // of the number of enums above. Add any new errors above this line if you
88 // want them to show up on UMA. Stuff below this line will not be sent to UMA
89 // but is used for other errors that are sent to Omaha. We don't assign any
90 // particular value for this enum so that it's just one more than the last
91 // one above and thus always represents the correct count of UMA metrics
92 // buckets, even when new enums are added above this line in future. See
93 // utils::SendErrorCodeToUma on how this enum is used.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070094 kUmaReportedMax,
David Zeuthena99981f2013-04-29 13:42:47 -070095
96 // use the 2xxx range to encode HTTP errors. These errors are available in
97 // Dremel with the individual granularity. But for UMA purposes, all these
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -070098 // errors are aggregated into one: kOmahaErrorInHTTPResponse.
99 kOmahaRequestHTTPResponseBase = 2000, // + HTTP response code
David Zeuthena99981f2013-04-29 13:42:47 -0700100
101 // TODO(jaysri): Move out all the bit masks into separate constants
102 // outside the enum as part of fixing bug 34369.
103 // Bit flags. Remember to update the mask below for new bits.
104
105 // Set if boot mode not normal.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700106 // TODO(garnold) This is very debatable value to use, knowing that the
107 // underlying type is a signed int (often, 32-bit). However, at this point
108 // there are parts of the ecosystem that expect this to be a negative value,
109 // so we preserve this semantics. This should be reconsidered if/when we
110 // modify the implementation of ErrorCode into a properly encapsulated class.
111 kDevModeFlag = 1 << 31,
David Zeuthena99981f2013-04-29 13:42:47 -0700112
113 // Set if resuming an interruped update.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700114 kResumedFlag = 1 << 30,
David Zeuthena99981f2013-04-29 13:42:47 -0700115
116 // Set if using a dev/test image as opposed to an MP-signed image.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700117 kTestImageFlag = 1 << 29,
David Zeuthena99981f2013-04-29 13:42:47 -0700118
119 // Set if using devserver or Omaha sandbox (using crosh autest).
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700120 kTestOmahaUrlFlag = 1 << 28,
David Zeuthena99981f2013-04-29 13:42:47 -0700121
122 // Mask that indicates bit positions that are used to indicate special flags
123 // that are embedded in the error code to provide additional context about
124 // the system in which the error was encountered.
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700125 kSpecialFlags = (kDevModeFlag | kResumedFlag | kTestImageFlag |
126 kTestOmahaUrlFlag)
David Zeuthena99981f2013-04-29 13:42:47 -0700127};
128
Gilad Arnoldd1c4d2d2014-06-05 14:07:53 -0700129inline std::ostream& operator<<(std::ostream& os, ErrorCode val) {
130 return os << static_cast<int>(val);
131}
132
David Zeuthena99981f2013-04-29 13:42:47 -0700133} // namespace chromeos_update_engine
134
Gilad Arnoldcf175a02014-07-10 16:48:47 -0700135#endif // UPDATE_ENGINE_ERROR_CODE_H_