Chromium Code Reviews| 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..5991f2ec0cd340292198b396bb7492f6b2fa09a1 |
| --- /dev/null |
| +++ b/headless/public/util/error_reporter.h |
| @@ -0,0 +1,47 @@ |
| +// 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 "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. |
| + void Push(); |
|
altimin
2016/04/11 14:49:57
Can we merge Push and SetName?
Sami
2016/04/11 15:04:10
When parsing a large object the expected usage pat
|
| + |
| + // 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(const char* 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_ |