aboutsummaryrefslogtreecommitdiff
path: root/c/err.h
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-09-03 15:28:56 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-09-03 15:28:56 +0200
commit6ae7e24675cff4ff6b808c3024f45083f35ced97 (patch)
tree2a47273f325d8367db2a8669691273f02ca83eb9 /c/err.h
parent2cd22c671c67deaf2c1fcb659e3262bf57552557 (diff)
downloadEpisodeBrowser-6ae7e24675cff4ff6b808c3024f45083f35ced97.tar.gz
Improve error handling.
Diffstat (limited to 'c/err.h')
-rw-r--r--c/err.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/c/err.h b/c/err.h
new file mode 100644
index 0000000..d4a9976
--- /dev/null
+++ b/c/err.h
@@ -0,0 +1,25 @@
+#ifndef ERR_H
+#define ERR_H
+
+#include <exception>
+#include <string>
+
+enum ErrType : unsigned char
+{
+ GENERIC,
+ WINDOWS,
+ WININET,
+ LIBXML2
+};
+
+struct Err
+{
+ std::wstring what;
+ Err(ErrType t, const wchar_t* fmt = L"%s");
+ inline Err(ErrType t, std::wstring fmt) : Err(t, fmt.c_str()) {}
+};
+
+/* Return a wide string describing exception. */
+std::wstring What(std::exception_ptr e = std::current_exception());
+
+#endif