Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 | |
| 5 #include "headless/public/util/error_reporter.h" | |
| 6 | |
| 7 #include <sstream> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 | |
| 11 namespace headless { | |
| 12 | |
| 13 ErrorReporter::ErrorReporter() {} | |
| 14 | |
| 15 ErrorReporter::~ErrorReporter() {} | |
| 16 | |
| 17 void ErrorReporter::Push() { | |
| 18 path_.push_back(nullptr); | |
| 19 } | |
| 20 | |
| 21 void ErrorReporter::Pop() { | |
| 22 path_.pop_back(); | |
| 23 } | |
| 24 | |
| 25 void ErrorReporter::SetName(const char* name) { | |
| 26 DCHECK(!path_.empty()); | |
| 27 path_[path_.size() - 1] = name; | |
| 28 } | |
| 29 | |
| 30 void ErrorReporter::AddError(const char* description) { | |
| 31 std::stringstream error; | |
| 32 for (size_t i = 0; i < path_.size(); i++) { | |
| 33 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.
| |
| 34 break; | |
| 35 if (i) | |
| 36 error << '.'; | |
| 37 error << path_[i]; | |
| 38 } | |
| 39 if (error.tellp()) | |
| 40 error << ": "; | |
| 41 error << description; | |
| 42 errors_.push_back(error.str()); | |
| 43 } | |
| 44 | |
| 45 bool ErrorReporter::HasErrors() const { | |
| 46 return !errors_.empty(); | |
| 47 } | |
| 48 | |
| 49 } // namespace headless | |
| OLD | NEW |