1 /* 2 * Copyright (C) 2006-2020 by the Widelands Development Team 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 */ 19 20 #ifndef WL_IO_FILESYSTEM_ZIP_EXCEPTIONS_H 21 #define WL_IO_FILESYSTEM_ZIP_EXCEPTIONS_H 22 23 #include <stdexcept> 24 25 /** 26 * Zip specific problems when working \e inside a zipfile. 27 * 28 * Problems with the zipfile itself or normal file operations should throw 29 * FileError or one of it's descendants with an appropriate message. E.g.: 30 * throw FileNotFoundError("ZipFilesystem::load", fname, 31 * "couldn't open file (from zipfile "+zipfilename_+")"); 32 */ 33 struct ZipOperationError : public std::logic_error { 34 ZipOperationError(const std::string& thrower, 35 const std::string& filename, 36 const std::string& zipfilename, 37 const std::string& message = "problem during zipfile operation") 38 : std::logic_error(thrower + ": " + message + " (working on '" + filename + "' in zipfile '" + 39 zipfilename + "')"), 40 thrower_(thrower), 41 filename_(filename), 42 zipfilename_(zipfilename) { 43 } 44 45 std::string thrower_; 46 std::string filename_; 47 std::string zipfilename_; 48 }; 49 50 #endif // end of include guard: WL_IO_FILESYSTEM_ZIP_EXCEPTIONS_H 51