1// This file is generated by ErrorSupport_cpp.template. 2 3// Copyright 2016 The Chromium Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style license that can be 5// found in the LICENSE file. 6 7//#include "ErrorSupport.h" 8 9{% for namespace in config.protocol.namespace %} 10namespace {{namespace}} { 11{% endfor %} 12 13ErrorSupport::ErrorSupport() { } 14ErrorSupport::~ErrorSupport() { } 15 16void ErrorSupport::setName(const char* name) 17{ 18 setName(String(name)); 19} 20 21void ErrorSupport::setName(const String& name) 22{ 23 DCHECK(m_path.size()); 24 m_path[m_path.size() - 1] = name; 25} 26 27void ErrorSupport::push() 28{ 29 m_path.push_back(String()); 30} 31 32void ErrorSupport::pop() 33{ 34 m_path.pop_back(); 35} 36 37void ErrorSupport::addError(const char* error) 38{ 39 addError(String(error)); 40} 41 42void ErrorSupport::addError(const String& error) 43{ 44 StringBuilder builder; 45 for (size_t i = 0; i < m_path.size(); ++i) { 46 if (i) 47 StringUtil::builderAppend(builder, '.'); 48 StringUtil::builderAppend(builder, m_path[i]); 49 } 50 StringUtil::builderAppend(builder, ": "); 51 StringUtil::builderAppend(builder, error); 52 m_errors.push_back(StringUtil::builderToString(builder)); 53} 54 55bool ErrorSupport::hasErrors() 56{ 57 return !!m_errors.size(); 58} 59 60String ErrorSupport::errors() 61{ 62 StringBuilder builder; 63 for (size_t i = 0; i < m_errors.size(); ++i) { 64 if (i) 65 StringUtil::builderAppend(builder, "; "); 66 StringUtil::builderAppend(builder, m_errors[i]); 67 } 68 return StringUtil::builderToString(builder); 69} 70 71{% for namespace in config.protocol.namespace %} 72} // namespace {{namespace}} 73{% endfor %} 74