File indexing completed on 2024-04-28 16:08:34
0001 /*************************************************************************** 0002 * Copyright (C) 2017 by Linuxstopmotion contributors; * 0003 * see the AUTHORS file for details. * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 0021 #ifndef UIEXCEPTION_H_ 0022 #define UIEXCEPTION_H_ 0023 0024 #include <exception> 0025 0026 /** 0027 * Exception requiring an error message to be displayed to the user. 0028 */ 0029 class UiException : public std::exception { 0030 public: 0031 /** Error, will stop the program. */ 0032 enum Error { 0033 /** Not an error, but a warning. */ 0034 IsWarning, 0035 /** Could not get exclusive lock on the command.log file. */ 0036 failedToGetExclusiveLock, 0037 /** Preferences file cannot be read. */ 0038 preferencesFileUnreadable, 0039 /** Preferences file cannot be loaded as XML. */ 0040 preferencesFileMalformed, 0041 /** Error where the parameter is the entirety of the message. */ 0042 ArbitraryError 0043 }; 0044 /** Warning, program will continue. */ 0045 enum Warning { 0046 /** Not a warning, but an error. */ 0047 IsError, 0048 /** Attempt to add a file that is not a .jpeg */ 0049 unsupportedImageType, 0050 /** Attempt to add a file that is not an .ogg */ 0051 invalidAudioFormat, 0052 /** Attempt to add a corrupt .ogg */ 0053 couldNotOpenFile, 0054 /** Sound or image could not be copied to ~/.stopmotion/images */ 0055 failedToCopyFilesToWorkspace, 0056 /** Audio driver could not be initialized */ 0057 failedToInitializeAudioDriver, 0058 /** Failed to write to preferences file */ 0059 failedToWriteToPreferencesFile 0060 }; 0061 explicit UiException(Warning); 0062 UiException(Warning, const char* param); 0063 explicit UiException(Error); 0064 UiException(Error, const char* param); 0065 ~UiException() throw(); 0066 const char* what() const throw(); 0067 /** 0068 * Returns the warning code, or @c IsError if it is an error. 0069 */ 0070 Warning warning() const; 0071 /** 0072 * Returns the error code, or @c IsWarning if it is a warning. 0073 */ 0074 Error error() const; 0075 /** 0076 * Returns the string parameter, or null if there is none. 0077 */ 0078 const char* string() const; 0079 private: 0080 void setStringParam(const char*); 0081 Error err; 0082 Warning warn; 0083 mutable const char* stringParam; 0084 mutable const char* out; 0085 }; 0086 0087 #endif