1#!/usr/bin/env python
2#
3# Copyright 2008 The Closure Linter Authors. All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS-IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17"""Linter error handler class that accumulates an array of errors."""
18
19__author__ = ('robbyw@google.com (Robert Walker)',
20              'ajp@google.com (Andy Perelson)')
21
22
23from closure_linter.common import errorhandler
24
25
26class ErrorAccumulator(errorhandler.ErrorHandler):
27  """Error handler object that accumulates errors in a list."""
28
29  def __init__(self):
30    self._errors = []
31
32  def HandleError(self, error):
33    """Append the error to the list.
34
35    Args:
36      error: The error object
37    """
38    self._errors.append(error)
39
40  def GetErrors(self):
41    """Returns the accumulated errors.
42
43    Returns:
44      A sequence of errors.
45    """
46    return self._errors
47