From a1c91f4695e208d5a8f80dc37b1818169b7829ff Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:24:59 +0200 Subject: 5.17 --- zen/file_error.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'zen/file_error.h') diff --git a/zen/file_error.h b/zen/file_error.h index f107a736..71619834 100644 --- a/zen/file_error.h +++ b/zen/file_error.h @@ -4,29 +4,31 @@ // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** -#ifndef FILEERROR_H_INCLUDED -#define FILEERROR_H_INCLUDED +#ifndef FILEERROR_H_INCLUDED_839567308565656789 +#define FILEERROR_H_INCLUDED_839567308565656789 #include #include "zstring.h" #include "utf.h" -#include "last_error.h" //we'll need this later anyway! +#include "sys_error.h" //we'll need this later anyway! namespace zen { -class FileError //Exception base class used to notify file/directory copy/delete errors +//A high-level exception class giving detailed context information for end users +class FileError { public: - explicit FileError(const std::wstring& message) : errorMessage(message) {} + explicit FileError(const std::wstring& msg) : msg_(msg) {} + FileError(const std::wstring& msg, const std::wstring& details) : msg_(msg + L"\n\n" + details) {} virtual ~FileError() {} - const std::wstring& toString() const { return errorMessage; } + const std::wstring& toString() const { return msg_; } private: - std::wstring errorMessage; + std::wstring msg_; }; -#define DEFINE_NEW_FILE_ERROR(X) struct X : public FileError { X(const std::wstring& message) : FileError(message) {} }; +#define DEFINE_NEW_FILE_ERROR(X) struct X : public FileError { X(const std::wstring& msg) : FileError(msg) {} X(const std::wstring& msg, const std::wstring& descr) : FileError(msg, descr) {} }; DEFINE_NEW_FILE_ERROR(ErrorNotExisting); DEFINE_NEW_FILE_ERROR(ErrorTargetExisting); @@ -35,7 +37,6 @@ DEFINE_NEW_FILE_ERROR(ErrorFileLocked); DEFINE_NEW_FILE_ERROR(ErrorDifferentVolume); - //----------- facilitate usage of std::wstring for error messages -------------------- //allow implicit UTF8 conversion: since std::wstring models a GUI string, convenience is more important than performance @@ -56,4 +57,4 @@ std::wstring fmtFileName(const Zstring& filename) } } -#endif // FILEERROR_H_INCLUDED +#endif //FILEERROR_H_INCLUDED_839567308565656789 -- cgit