Chromium Code Reviews| Index: headless/public/util/error_reporter.cc |
| diff --git a/headless/public/util/error_reporter.cc b/headless/public/util/error_reporter.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b004c4b7423312e705a4ca7f092a2ecf0d014b26 |
| --- /dev/null |
| +++ b/headless/public/util/error_reporter.cc |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "headless/public/util/error_reporter.h" |
| + |
| +#include <sstream> |
| + |
| +#include "base/logging.h" |
| + |
| +namespace headless { |
| + |
| +ErrorReporter::ErrorReporter() {} |
| + |
| +ErrorReporter::~ErrorReporter() {} |
| + |
| +void ErrorReporter::Push() { |
| + path_.push_back(nullptr); |
| +} |
| + |
| +void ErrorReporter::Pop() { |
| + path_.pop_back(); |
| +} |
| + |
| +void ErrorReporter::SetName(const char* name) { |
| + DCHECK(!path_.empty()); |
| + path_[path_.size() - 1] = name; |
| +} |
| + |
| +void ErrorReporter::AddError(const char* description) { |
| + std::stringstream error; |
| + for (size_t i = 0; i < path_.size(); i++) { |
| + if (!path_[i]) |
|
altimin
2016/04/11 15:30:05
I wonder if ignoring the rest of the path_ is a go
Sami
2016/04/11 15:37:15
Good idea, added.
|
| + break; |
| + if (i) |
| + error << '.'; |
| + error << path_[i]; |
| + } |
| + if (error.tellp()) |
| + error << ": "; |
| + error << description; |
| + errors_.push_back(error.str()); |
| +} |
| + |
| +bool ErrorReporter::HasErrors() const { |
| + return !errors_.empty(); |
| +} |
| + |
| +} // namespace headless |