Savarese Software Research Corporation
Error.h
Go to the documentation of this file.
1 /* Copyright 2006 Savarese Software Research Corporation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.savarese.com/software/ApacheLicense-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
21 #ifndef __SSRC_SPREAD_ERROR_H
22 #define __SSRC_SPREAD_ERROR_H
23 
25 
26 // sp.h includes stddef.h, so we need to include it before sp.h in
27 // order to ensure it gets skipped while inside the Spread namespace.
28 #include <cstddef>
29 
31 # include <sp.h>
33 
35 
40 class Error {
41  const int _error;
42 
43 public:
44 
51  enum Code {
52  AcceptSession = ACCEPT_SESSION,
53  IllegalSpread = ILLEGAL_SPREAD,
54  CouldNotConnect = COULD_NOT_CONNECT,
55  RejectQuota = REJECT_QUOTA,
56  RejectNoName = REJECT_NO_NAME,
57  RejectIllegalName = REJECT_ILLEGAL_NAME,
58  RejectNotUnique = REJECT_NOT_UNIQUE,
59  RejectVersion = REJECT_VERSION,
60  ConnectionClosed = CONNECTION_CLOSED,
61  RejectAuth = REJECT_AUTH,
62  IllegalSession = ILLEGAL_SESSION,
63  IllegalService = ILLEGAL_SERVICE,
64  IllegalMessage = ILLEGAL_MESSAGE,
65  IllegalGroup = ILLEGAL_GROUP,
66  BufferTooShort = BUFFER_TOO_SHORT,
67  GroupsTooShort = GROUPS_TOO_SHORT,
68  MessageTooLong = MESSAGE_TOO_LONG
69 #if (LIBSSRCSPREAD_SPREAD_MAJOR_VERSION >= 4)
70  , NetErrorOnSession = NET_ERROR_ON_SESSION
71 #endif
72 #if (LIBSSRCSPREAD_SPREAD_MAJOR_VERSION >= 5)
73  , IllegalTime = ILLEGAL_TIME
74 #endif
75  };
76 
81  explicit Error(const int err) : _error(err) { }
82 
87  int error() const {
88  return _error;
89  }
90 
96  void print() const {
97  Spread::SP_error(_error);
98  }
99 };
100 
101 
110 class BufferSizeError : public Error {
111  const unsigned int _size;
112 
113 public:
114 
121  BufferSizeError(const int err, const unsigned int size) :
122  Error(err), _size(size)
123  { }
124 
129  unsigned int size() const {
130  return _size;
131  }
132 };
133 
135 
136 #endif

Savarese Software Research Corporation
Copyright © 2006-2015 Savarese Software Research Corporation. All rights reserved.