chromium/remoting/base/errors.h

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_BASE_ERRORS_H_
#define REMOTING_BASE_ERRORS_H_

#include <string>

namespace remoting {

// Workaround a dependency issue with management_ui_handler_unittest.cc, which
// includes chrome/browser/ash without checking the platform.
namespace proto {
enum ErrorCode : int;
}  // namespace proto

// If this enum is modified, please also modify the enums in these file:
// * chrome/browser/ash/policy/remote_commands/crd/crd_remote_command_utils.h:
//     ExtendedStartCrdSessionResultCode
// * chrome/browser/ash/policy/remote_commands/crd/crd_remote_command_utils.cc:
//     ToExtendedStartCrdSessionResultCode, ToStartCrdSessionResultCode
// * remoting/base/errors.cc: kErrorCodeNames
// * remoting/host/mojom/desktop_session.mojom: ProtocolErrorCode
// * tools/metrics/histograms/metadata/enterprise/enums.xml:
//     EnterpriseCrdSessionResultCode
//
// DO NOT change existing values in this enum, since it would lead to version
// skew problems.
enum class ErrorCode {};

bool ParseErrorCode(const std::string& name, ErrorCode* result);

// Returns the literal string of |error|.
const char* ErrorCodeToString(ErrorCode error);

// Converts a protocol ErrorCode to the protobuf ErrorCode.
proto::ErrorCode ErrorCodeToProtoEnum(ErrorCode error);

}  // namespace remoting

#endif  // REMOTING_BASE_ERRORS_H_