Lattice Microbes 2.5
This is for whole cell modeling
Loading...
Searching...
No Matches
Exceptions.h
Go to the documentation of this file.
1/*
2 * University of Illinois Open Source License
3 * Copyright 2008-2018 Luthey-Schulten Group,
4 * All rights reserved.
5 *
6 * Developed by: Luthey-Schulten Group
7 * University of Illinois at Urbana-Champaign
8 * http://www.scs.uiuc.edu/~schulten
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy of
11 * this software and associated documentation files (the Software), to deal with
12 * the Software without restriction, including without limitation the rights to
13 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14 * of the Software, and to permit persons to whom the Software is furnished to
15 * do so, subject to the following conditions:
16 *
17 * - Redistributions of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimers.
19 *
20 * - Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimers in the documentation
22 * and/or other materials provided with the distribution.
23 *
24 * - Neither the names of the Luthey-Schulten Group, University of Illinois at
25 * Urbana-Champaign, nor the names of its contributors may be used to endorse or
26 * promote products derived from this Software without specific prior written
27 * permission.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
32 * THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
33 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
34 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35 * OTHER DEALINGS WITH THE SOFTWARE.
36 *
37 * Author(s): Elijah Roberts
38 */
39
40#ifndef LM_EXCEPTIONS_H_
41#define LM_EXCEPTIONS_H_
42
43#include <cstdio>
44#include <exception>
45
46namespace lm
47{
48
54class Exception : public std::exception
55{
56protected:
57 static const int MAX_MESSAGE_SIZE = 1025;
59
60public:
62 Exception(const char * message="") {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s", message);}
64 Exception(const char * message, const int arg) {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %d", message, arg);}
66 Exception(const char * message, const int arg1, const int arg2) {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %d, %d", message, arg1, arg2);}
68 Exception(const char * message, const int arg1, const int arg2, const int arg3) {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %d, %d, %d", message, arg1, arg2, arg3);}
70 Exception(const char * message, const char * arg) {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %s", message, arg);}
72 Exception(const char * message, const char * arg1, const char* arg2) {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %s, %s", message, arg1, arg2);}
74 Exception(const char * message, const char * arg1, const char* arg2, const char* arg3) {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %s, %s, %s", message, arg1, arg2, arg3);}
76 Exception(const char * message, const char * arg1, const int arg2) {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %s, %d", message, arg1, arg2);}
78 Exception(const char * message, const char * arg1, const int arg2, const int arg3) {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %s, %d, %d", message, arg1, arg2, arg3);}
80 Exception(const char * message, const int arg, const char * file, const int line) {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %d (%s:%d)", message, arg, file, line);}
82 Exception(const char * message, const char * arg, const char * file, const int line) {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %s (%s:%d)", message, arg, file, line);}
84 virtual ~Exception() throw() {}
85
88 virtual const char * what() const throw() {return messageBuffer;}
89};
90
94{
95public:
97 CommandLineArgumentException(const char* message, const char* arg1) : Exception(message, arg1) {}
98};
99
103{
104public:
105 InvalidArgException(const char* argMessage) : Exception("Invalid argument", argMessage) {}
106 InvalidArgException(const char* arg, const char* argMessage) : Exception("Invalid argument", arg, argMessage) {}
107 InvalidArgException(const char* arg, const char* argMessage, const char * argMessageParameter) : Exception("Invalid argument", arg, argMessage, argMessageParameter) {}
108 InvalidArgException(const char* arg, const char* argMessage, const int argMessageParameter) : Exception("Invalid argument", arg, argMessage, argMessageParameter) {}
109 InvalidArgException(const char* arg, const char* argMessage, const int argMessageParameter1, const int argMessageParameter2) : Exception() {snprintf(messageBuffer,MAX_MESSAGE_SIZE,"%s: %s, %s (%d,%d)", "Invalid argument", arg, argMessage, argMessageParameter1, argMessageParameter2);}
110};
111
114class IOException : public Exception
115{
116public:
117 IOException(const char* message, const char* arg) : Exception("IO exception", message, arg) {}
118 IOException(const char* message, const int arg) : Exception("IO exception", message, arg) {}
119};
120
121}
122
123#endif
Exception(const char *message="")
Create an Exception.
Definition Exceptions.h:62
IOException(const char *message, const char *arg)
Definition Exceptions.h:117
CommandLineArgumentException(const char *message, const char *arg1)
Definition Exceptions.h:97
CommandLineArgumentException(const char *message)
Definition Exceptions.h:96
Exception(const char *message="")
Create an Exception.
Definition Exceptions.h:62
Exception(const char *message, const char *arg1, const char *arg2)
Create and Exception with two error strings.
Definition Exceptions.h:72
char messageBuffer[MAX_MESSAGE_SIZE]
Definition Exceptions.h:58
virtual ~Exception()
Destroy the Exception.
Definition Exceptions.h:84
Exception(const char *message, const int arg1, const int arg2)
Create and Exception with two integer error codes.
Definition Exceptions.h:66
virtual const char * what() const
Get the error string.
Definition Exceptions.h:88
Exception(const char *message, const char *arg1, const int arg2)
Create and Exception with one integer error code and one error string.
Definition Exceptions.h:76
static const int MAX_MESSAGE_SIZE
Definition Exceptions.h:57
Exception(const char *message, const int arg, const char *file, const int line)
Create and Exception with one integer error code, a file and a line number.
Definition Exceptions.h:80
Exception(const char *message, const char *arg1, const int arg2, const int arg3)
Create and Exception with two integer error codes and one error string.
Definition Exceptions.h:78
Exception(const char *message, const char *arg1, const char *arg2, const char *arg3)
Create and Exception with three error strings.
Definition Exceptions.h:74
Exception(const char *message, const int arg)
Create and Exception with one integer error code.
Definition Exceptions.h:64
Exception(const char *message, const char *arg, const char *file, const int line)
Create and Exception with one error string, a file and a line number.
Definition Exceptions.h:82
Exception(const char *message, const char *arg)
Create and Exception with one error string.
Definition Exceptions.h:70
Exception(const char *message, const int arg1, const int arg2, const int arg3)
Create and Exception with three integer error codes.
Definition Exceptions.h:68
IOException(const char *message, const char *arg)
Definition Exceptions.h:117
IOException(const char *message, const int arg)
Definition Exceptions.h:118
InvalidArgException(const char *arg, const char *argMessage)
Definition Exceptions.h:106
InvalidArgException(const char *arg, const char *argMessage, const int argMessageParameter1, const int argMessageParameter2)
Definition Exceptions.h:109
InvalidArgException(const char *arg, const char *argMessage, const char *argMessageParameter)
Definition Exceptions.h:107
InvalidArgException(const char *arg, const char *argMessage, const int argMessageParameter)
Definition Exceptions.h:108
InvalidArgException(const char *argMessage)
Definition Exceptions.h:105
Definition SimulationParameters.h:51
Definition Capsule.cpp:46