00001 /*************************************************************************** 00002 * Copyright (C) 2001 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the conexus library. * 00006 * * 00007 * The conexus library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The conexus library is distributed in the hope that it will be * 00012 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * 00013 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef CONEXUSEXCEPT_WRITE_H 00020 #define CONEXUSEXCEPT_WRITE_H 00021 00022 #include <conexus/except.h> 00023 #include <cstring> 00024 00025 namespace Conexus 00026 { 00027 00033 class write_exception: public conexus_exception 00034 { 00035 public: 00036 write_exception() : conexus_exception ( "Unknown exception, write failed.",0,"write" ) 00037 { } 00038 write_exception ( int e ) : conexus_exception ( strerror ( e ),e,"write" ) 00039 { } 00040 write_exception ( const std::string s ) : conexus_exception ( s,0,"write" ) 00041 { } 00042 }; 00043 00044 namespace exception 00045 { 00046 00047 namespace write 00048 { 00049 00056 class retry: public write_exception 00057 { 00058 public: 00059 retry() : write_exception ( "Unknown exception, write failed but should be retried." ) 00060 { } 00061 retry ( int e ) : write_exception ( e ) 00062 { } 00063 retry ( const std::string s ) : write_exception ( s ) 00064 { } 00065 }; 00066 00074 class would_block: public retry 00075 { 00076 public: 00077 would_block() : retry ( EAGAIN ) 00078 { } 00079 } 00080 ; 00081 00088 class bad_fd: public write_exception 00089 { 00090 public: 00091 bad_fd() : write_exception ( EBADF ) 00092 { } 00093 }; 00094 00101 class connection_reset: public write_exception 00102 { 00103 public: 00104 connection_reset() : write_exception ( ECONNRESET ) 00105 { } 00106 }; 00107 00114 class destination_address_required: public write_exception 00115 { 00116 public: 00117 destination_address_required() : write_exception ( EDESTADDRREQ ) 00118 { } 00119 }; 00120 00121 00128 class invalid_user_space_address: public write_exception 00129 { 00130 public: 00131 invalid_user_space_address() : write_exception ( EFAULT ) 00132 { } 00133 }; 00134 00141 class interrupted: public retry 00142 { 00143 public: 00144 interrupted() : retry ( EINTR ) 00145 { } 00146 }; 00147 00148 00155 class invalid_argument: public write_exception 00156 { 00157 public: 00158 invalid_argument() : write_exception ( EINVAL ) 00159 { } 00160 }; 00161 00170 class is_connected: public write_exception 00171 { 00172 public: 00173 is_connected() : write_exception ( EISCONN ) 00174 { } 00175 }; 00176 00177 00185 class message_size: public write_exception 00186 { 00187 public: 00188 message_size() : write_exception ( EMSGSIZE ) 00189 { } 00190 }; 00191 00202 class no_buffers: public retry 00203 { 00204 public: 00205 no_buffers() : retry ( ENOBUFS ) 00206 { } 00207 }; 00208 00209 00216 class no_memory: public write_exception 00217 { 00218 public: 00219 no_memory() : write_exception ( ENOMEM ) 00220 { } 00221 }; 00222 00229 class permission_denied: public write_exception 00230 { 00231 public: 00232 permission_denied() : write_exception ( EACCES ) 00233 { } 00234 }; 00235 00242 class not_connected: public write_exception 00243 { 00244 public: 00245 not_connected() : write_exception ( ENOTCONN ) 00246 { } 00247 }; 00248 00255 class not_socket: public write_exception 00256 { 00257 public: 00258 not_socket() : write_exception ( ENOTSOCK ) 00259 { } 00260 }; 00261 00262 00270 class operation_not_supported: public write_exception 00271 { 00272 public: 00273 operation_not_supported() : write_exception ( EOPNOTSUPP ) 00274 { } 00275 }; 00276 00277 00286 class pipe: public write_exception 00287 { 00288 public: 00289 pipe() : write_exception ( EPIPE ) 00290 { } 00291 }; 00292 00301 class connection_refused: public write_exception 00302 { 00303 public: 00304 connection_refused() : write_exception ( ECONNREFUSED ) 00305 { } 00306 }; 00307 00313 class no_default_remote_address: public write_exception 00314 { 00315 public: 00316 no_default_remote_address() : write_exception ( "Socket cannot send because a default remote address has not been set." ) 00317 { } 00318 }; 00319 00325 class no_sendto_without_address: public write_exception 00326 { 00327 public: 00328 no_sendto_without_address() : write_exception ( "Socket is not capable of sendto without an address." ) 00329 { } 00330 }; 00331 00337 class not_opened: public write_exception 00338 { 00339 public: 00340 not_opened() : write_exception ( "Trying to write on I/O that cannot open." ) 00341 { } 00342 }; 00343 00349 class read_only: public write_exception 00350 { 00351 public: 00352 read_only() : write_exception ( "Trying to write to a read only I/O." ) 00353 { } 00354 }; 00355 00363 class timeout: public retry 00364 { 00365 public: 00366 timeout() : retry ( ETIMEDOUT ) 00367 { } 00368 }; 00369 00377 class disconnected: public write_exception 00378 { 00379 public: 00380 disconnected() : write_exception ( "Trying to write from a socket where the peer has performed an orderly shutdown." ) 00381 { } 00382 }; 00383 00384 00385 00386 00387 } 00388 00389 } 00390 00391 } 00392 00393 #endif // CONEXUSSEND_ERROR_H