mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-25 15:35:49 -04:00
Unify common error category message into a function
This commit is contained in:
parent
4f0e18cbfd
commit
275bdba132
4 changed files with 14 additions and 5 deletions
|
@ -33,6 +33,7 @@
|
||||||
#include "serialiser/rsserializable.h"
|
#include "serialiser/rsserializable.h"
|
||||||
#include "serialiser/rstypeserializer.h"
|
#include "serialiser/rstypeserializer.h"
|
||||||
#include "util/rstime.h"
|
#include "util/rstime.h"
|
||||||
|
#include "util/rsdebug.h"
|
||||||
|
|
||||||
class RsEvents;
|
class RsEvents;
|
||||||
|
|
||||||
|
@ -126,8 +127,7 @@ struct RsEventsErrorCategory: std::error_category
|
||||||
case RsEventsErrorNum::INVALID_HANDLER_ID:
|
case RsEventsErrorNum::INVALID_HANDLER_ID:
|
||||||
return "Invalid handler id";
|
return "Invalid handler id";
|
||||||
default:
|
default:
|
||||||
return "Error message for error: " + std::to_string(ev) +
|
return rsErrorNotInCategory(ev, name());
|
||||||
" not available in category: " + name();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "util/rstime.h"
|
#include "util/rstime.h"
|
||||||
#include "retroshare/rsevents.h"
|
#include "retroshare/rsevents.h"
|
||||||
#include "util/rsmemory.h"
|
#include "util/rsmemory.h"
|
||||||
|
#include "util/rsdebug.h"
|
||||||
|
|
||||||
class RsFiles;
|
class RsFiles;
|
||||||
|
|
||||||
|
@ -63,8 +64,7 @@ struct RsFilesErrorCategory: std::error_category
|
||||||
case RsFilesErrorNum::FILES_HANDLE_NOT_FOUND:
|
case RsFilesErrorNum::FILES_HANDLE_NOT_FOUND:
|
||||||
return "Files handle not found";
|
return "Files handle not found";
|
||||||
default:
|
default:
|
||||||
return "Error message for error: " + std::to_string(ev) +
|
return rsErrorNotInCategory(ev, name());
|
||||||
" not available in category: " + name();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,12 @@ std::ostream &operator<<(std::ostream& out, const std::error_condition& err)
|
||||||
<< " category: " << err.category().name();
|
<< " category: " << err.category().name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string rsErrorNotInCategory(int errNum, const std::string& categoryName)
|
||||||
|
{
|
||||||
|
return "Error message for error: " + std::to_string(errNum) +
|
||||||
|
" not available in category: " + categoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -61,6 +61,10 @@ enum class RsLoggerCategories
|
||||||
/** Stream helper for std::error_condition */
|
/** Stream helper for std::error_condition */
|
||||||
std::ostream &operator<<(std::ostream& out, const std::error_condition& err);
|
std::ostream &operator<<(std::ostream& out, const std::error_condition& err);
|
||||||
|
|
||||||
|
/** Provide unkown error message for all error categories to avoid duplicating
|
||||||
|
* the message around */
|
||||||
|
std::string rsErrorNotInCategory(int errNum, const std::string& categoryName);
|
||||||
|
|
||||||
|
|
||||||
template <RsLoggerCategories CATEGORY>
|
template <RsLoggerCategories CATEGORY>
|
||||||
struct t_RsLogger : std::ostringstream
|
struct t_RsLogger : std::ostringstream
|
||||||
|
@ -201,7 +205,6 @@ struct RsNoDbg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue