model_error.cc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2017 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 "components/sync/model/model_error.h"
  5. #include "components/sync/model/sync_error.h"
  6. namespace syncer {
  7. ModelError::ModelError(const base::Location& location,
  8. const std::string& message)
  9. : location_(location), message_(message) {}
  10. ModelError::~ModelError() = default;
  11. const base::Location& ModelError::location() const {
  12. return location_;
  13. }
  14. const std::string& ModelError::message() const {
  15. return message_;
  16. }
  17. std::string ModelError::ToString() const {
  18. return location_.ToString() + std::string(": ") + message_;
  19. }
  20. // TODO(https://crbug.com/1057577): Remove this once ProcessSyncChanges in
  21. // SyncableService has been refactored.
  22. absl::optional<ModelError> ConvertToModelError(const SyncError& sync_error) {
  23. if (sync_error.IsSet()) {
  24. return ModelError(sync_error.location(), sync_error.message());
  25. }
  26. return absl::nullopt;
  27. }
  28. } // namespace syncer