Savarese Software Research Corporation
Error.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright 2006 Savarese Software Research Corporation
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.savarese.com/software/ApacheLicense-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00023 #ifndef __SSRC_SPREAD_ERROR_H
00024 #define __SSRC_SPREAD_ERROR_H
00025 
00026 #include <ssrc/libssrcspread-packages.h>
00027 
00028 __BEGIN_NS_SPREAD_INCLUDE
00029 # include <sp.h>
00030 __END_NS_SPREAD_INCLUDE
00031 
00032 __BEGIN_NS_SSRC_SPREAD
00033 
00038 class Error {
00039   const int _error;
00040 
00041 public:
00042 
00049   enum Code {
00050     AcceptSession     = ACCEPT_SESSION,
00051     IllegalSpread     = ILLEGAL_SPREAD,
00052     CouldNotConnect   = COULD_NOT_CONNECT,
00053     RejectQuota       = REJECT_QUOTA,
00054     RejectNoName      = REJECT_NO_NAME,
00055     RejectIllegalName = REJECT_ILLEGAL_NAME,
00056     RejectNotUnique   = REJECT_NOT_UNIQUE,
00057     RejectVersion     = REJECT_VERSION,
00058     ConnectionClosed  = CONNECTION_CLOSED,
00059     RejectAuth        = REJECT_AUTH,
00060     IllegalSession    = ILLEGAL_SESSION,
00061     IllegalService    = ILLEGAL_SERVICE,
00062     IllegalMessage    = ILLEGAL_MESSAGE,
00063     IllegalGroup      = ILLEGAL_GROUP,
00064     BufferTooShort    = BUFFER_TOO_SHORT,
00065     GroupsTooShort    = GROUPS_TOO_SHORT,
00066     MessageTooLong    = MESSAGE_TOO_LONG
00067 #ifdef LIBSSRCSPREAD_HAVE_SPREAD4
00068     , NetErrorOnSession = NET_ERROR_ON_SESSION
00069 #endif
00070   };
00071 
00076   explicit Error(const int err) : _error(err) { }
00077 
00082   int error() const {
00083     return _error;
00084   }
00085 
00091   void print() const {
00092     Spread::SP_error(_error);
00093   }
00094 };
00095 
00096 
00105 class BufferSizeError : public Error {
00106   const unsigned int _size;
00107 
00108 public:
00109 
00116   BufferSizeError(const int err, const unsigned int size) :
00117     Error(err), _size(size)
00118   { }
00119 
00124   unsigned int size() const {
00125     return _size;
00126   }
00127 };
00128 
00129 __END_NS_SSRC_SPREAD
00130 
00131 #endif

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