libfoedus-core
FOEDUS Core Library
error_stack_batch.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
19 
20 #include <iostream>
21 #include <sstream>
22 
23 namespace foedus {
25  const char* filename, const char* func, uint32_t linenum) const {
26  if (!is_error()) {
27  return kRetOk;
28  } else if (error_batch_.size() == 1) {
29  return error_batch_[0];
30  } else {
31  // there were multiple errors. we must batch them.
32  std::stringstream message;
33  for (size_t i = 0; i < error_batch_.size(); ++i) {
34  if (i > 0) {
35  message << std::endl;
36  }
37  message << "Error[" << i << "]:" << error_batch_[i];
38  }
39  return ErrorStack(filename, func, linenum, kErrorCodeBatchedError, message.str().c_str());
40  }
41 }
42 
43 std::ostream& operator<<(std::ostream& o, const ErrorStackBatch& obj) {
44  o << SUMMARIZE_ERROR_BATCH(obj);
45  return o;
46 }
47 
48 } // namespace foedus
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
std::ostream & operator<<(std::ostream &o, const Epoch &v)
Definition: epoch.cpp:23
Batches zero or more ErrorStack objects to represent in one ErrorStack.
ErrorStack summarize(const char *filename, const char *func, uint32_t linenum) const
Instantiate an ErrorStack object that summarizes all errors in this batch.
0x0004 : "GENERAL: More than one errors observed" .
Definition: error_code.hpp:108
#define SUMMARIZE_ERROR_BATCH(x)
This macro calls ErrorStackBatch::summarize() with automatically provided parameters.
bool is_error() const
Returns whether there was any error.
const ErrorStack kRetOk
Normal return value for no-error case.