file_transfer_helpers.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2018 The Chromium 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. #include "remoting/protocol/file_transfer_helpers.h"
  5. namespace remoting {
  6. namespace protocol {
  7. FileTransfer_Error MakeFileTransferError(
  8. base::Location location,
  9. FileTransfer_Error_Type type,
  10. absl::optional<int32_t> api_error_code) {
  11. FileTransfer_Error error;
  12. error.set_type(type);
  13. if (api_error_code) {
  14. error.set_api_error_code(*api_error_code);
  15. }
  16. error.set_function(location.function_name());
  17. error.set_source_file(location.file_name());
  18. error.set_line_number(location.line_number());
  19. return error;
  20. }
  21. std::ostream& operator<<(std::ostream& stream,
  22. const FileTransfer_Error& error) {
  23. stream << "[" << error.source_file() << ":" << error.line_number() << " ("
  24. << error.function() << ")";
  25. if (error.has_api_error_code()) {
  26. stream << ": " << error.api_error_code();
  27. }
  28. stream << "]";
  29. return stream;
  30. }
  31. } // namespace protocol
  32. } // namespace remoting