| 1 | // tThrow.cpp  |
| 2 | //  |
| 3 | // Base classes for objects that may be thrown. Mostly warnings and errors.  |
| 4 | //  |
| 5 | // Copyright (c) 2004-2006, 2017 Tristan Grimmer.  |
| 6 | // Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby  |
| 7 | // granted, provided that the above copyright notice and this permission notice appear in all copies.  |
| 8 | //  |
| 9 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL  |
| 10 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,  |
| 11 | // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN  |
| 12 | // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR  |
| 13 | // PERFORMANCE OF THIS SOFTWARE.  |
| 14 |   |
| 15 | #include "System/tPrint.h"  |
| 16 | #include "System/tThrow.h"  |
| 17 |   |
| 18 |   |
| 19 | // All errors that can be thrown by any library module are derived from this. By catching exceptions of the tError  |
| 20 | // type all possibilities can be covered. Conversely, derived classes can be caught for more control over who handles  |
| 21 | // what type of error.  |
| 22 | tError::tError(const char* format, ...) :  |
| 23 | Message("Error: " )  |
| 24 | {  |
| 25 | va_list marker;  |
| 26 | va_start(marker, format);  |
| 27 | Message += tvsPrintf(format, marker);  |
| 28 | }  |
| 29 |   |
| 30 |   |
| 31 | tError::tError(const tString& message) :  |
| 32 | Message("Error: " )  |
| 33 | {  |
| 34 | Message += message;  |
| 35 | }  |
| 36 |   |
| 37 |   |
| 38 | tError::tError() :  |
| 39 | Message("Error: Unknown." )  |
| 40 | {  |
| 41 | }  |
| 42 |   |
| 43 |   |
| 44 | tWarning::tWarning(const char* format, ...) :  |
| 45 | Message("Warning: " )  |
| 46 | {  |
| 47 | va_list marker;  |
| 48 | va_start(marker, format);  |
| 49 | Message += tvsPrintf(format, marker);  |
| 50 | }  |
| 51 |   |
| 52 |   |
| 53 | tWarning::tWarning(const tString& message) :  |
| 54 | Message("Warning: " )  |
| 55 | {  |
| 56 | Message += message;  |
| 57 | }  |
| 58 |   |
| 59 |   |
| 60 | tWarning::tWarning() :  |
| 61 | Message("Warning: Generic." )  |
| 62 | {  |
| 63 | }  |
| 64 | |