ScaleOut C++ Native Client API  5.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
pmicli_invoke_exception.h
1 /*
2  Copyright (c) 2013 by ScaleOut Software, Inc.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #pragma once
18 
19 #include "soss_client/soss_key.h"
20 #include "soss_pmicli.h"
21 
22 namespace sosscli { namespace exceptions {
23 
29 {
30 public:
32  : return_code_(0)
33  {
34  }
35 
37  PmiCliUserExceptionCode(SOSSPMI_EXCEPTION * psosspmi_exception)
38  {
39  return_code_ = psosspmi_exception->code;
40  exception_source_ = (psosspmi_exception->is_eval) ? ExceptionSource::EVAL : ExceptionSource::MERGE;
41  key_ = SossKey(psosspmi_exception->key);
42  }
43 
45  PmiCliUserExceptionCode(const SOSSPMI_EXCEPTION & psosspmi_exception)
46  {
47  return_code_ = psosspmi_exception.code;
48  exception_source_ = (psosspmi_exception.is_eval) ? ExceptionSource::EVAL : ExceptionSource::MERGE;
49  key_ = SossKey(psosspmi_exception.key);
50  }
51 
53  virtual ~PmiCliUserExceptionCode(void) {}
54 
57  {
58  MERGE,
59  EVAL
60  };
61 
62 public:
64  int return_code() const { return return_code_; }
65 
67  ExceptionSource exception_source() const { return exception_source_; }
68 
70  SossKey key() const { return key_; }
71 
72 private:
74  unsigned long return_code_;
75 
77  ExceptionSource exception_source_;
78 
80  SossKey key_;
81 };
82 
83 
86 struct PmiCliInvokeUserException: virtual std::exception, virtual boost::exception
87 {
89  PmiCliInvokeUserException(std::vector<PmiCliUserExceptionCode> const &exceptions_vec)
90  {
91  pmi_exceptions = exceptions_vec;
92  }
93 
94  virtual ~PmiCliInvokeUserException() throw() {}
95 
98  virtual const char* what() const throw()
99  {
100  return "Exceptions occurred during pmicli_invoke() originating from eval/merge callback functions; see inner pmi_exceptions for details.";
101  }
102 
104  std::vector<PmiCliUserExceptionCode> pmi_exceptions;
105 };
106 
107 } }
108