00001 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 00002 /* 00003 * mitie 00004 * Copyright (C) Jason Spencer 2009 <mitie@jasonspencer.org> 00005 * 00006 * mitie is free software: you can redistribute it and/or modify it 00007 * under the terms of the GNU General Public License as published by the 00008 * Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * mitie is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00014 * See the GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef _CJMATRIXEXCEPT_H_ 00021 #define _CJMATRIXEXCEPT_H_ 1 00022 00023 #include <new> // bad_alloc 00024 #include <stdexcept> //range_error runtime_error 00025 #include <ios> // ios_base::failure 00026 #include <string> 00027 00028 struct E_CjMatrix_Exception { }; // just an interface to label exceptions that we've part handled 00029 00030 struct E_CjMatrix_MemoryAllocFail : public E_CjMatrix_Exception, public std::bad_alloc { 00031 explicit E_CjMatrix_MemoryAllocFail() {} 00032 }; 00033 00034 struct E_CjMatrix_FileError : public E_CjMatrix_Exception, public std::ios_base::failure { 00035 explicit E_CjMatrix_FileError (const std::string& message) : std::ios_base::failure(message) {} 00036 // virtual ~E_CjMatrix_FileError() throw() {}; 00037 }; 00038 00039 struct E_CjMatrix_SizeError : public E_CjMatrix_Exception, public std::range_error { 00040 explicit E_CjMatrix_SizeError (const std::string& message) : std::range_error(message) {} 00041 // virtual ~E_CjMatrix_SizeError() throw() {}; 00042 }; 00043 00044 struct E_CjMatrix_BoundsError : public E_CjMatrix_Exception, public std::runtime_error { 00045 explicit E_CjMatrix_BoundsError (const std::string& message) : std::runtime_error(message) {} 00046 // virtual ~E_CjMatrix_BoundsError() throw() {}; 00047 }; 00048 00049 #endif // _CJMATRIXEXCEPT_H_