Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: headless/public/util/error_reporter.h

Issue 1867753005: headless: Add error reporter utility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK that path has no more components Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/BUILD.gn ('k') | headless/public/util/error_reporter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/util/error_reporter.h
diff --git a/headless/public/util/error_reporter.h b/headless/public/util/error_reporter.h
new file mode 100644
index 0000000000000000000000000000000000000000..d7eb5e96d2148a881c6c86ad3a87f341119ff0e6
--- /dev/null
+++ b/headless/public/util/error_reporter.h
@@ -0,0 +1,48 @@
+// 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.
+
+#ifndef HEADLESS_PUBLIC_UTIL_ERROR_REPORTER_H_
+#define HEADLESS_PUBLIC_UTIL_ERROR_REPORTER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/strings/string_piece.h"
+#include "headless/public/headless_export.h"
+
+namespace headless {
+
+// Tracks errors which are encountered while parsing client API types.
+class HEADLESS_EXPORT ErrorReporter {
+ public:
+ ErrorReporter();
+ ~ErrorReporter();
+
+ // Enter a new nested parsing context. It will initially have a null name.
+ void Push();
+
+ // Leave the current parsing context, returning to the previous one.
+ void Pop();
+
+ // Set the name of the current parsing context. |name| must be a string with
+ // application lifetime.
+ void SetName(const char* name);
+
+ // Report an error in the current parsing context.
+ void AddError(base::StringPiece description);
+
+ // Returns true if any errors have been reported so far.
+ bool HasErrors() const;
+
+ // Returns a list of reported errors.
+ const std::vector<std::string>& errors() const { return errors_; }
+
+ private:
+ std::vector<const char*> path_;
+ std::vector<std::string> errors_;
+};
+
+} // namespace headless
+
+#endif // HEADLESS_PUBLIC_UTIL_ERROR_REPORTER_H_
« no previous file with comments | « headless/BUILD.gn ('k') | headless/public/util/error_reporter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698