aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/except.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zencore/except.cpp')
-rw-r--r--src/zencore/except.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/zencore/except.cpp b/src/zencore/except.cpp
index 65f5ebc62..f98743ea9 100644
--- a/src/zencore/except.cpp
+++ b/src/zencore/except.cpp
@@ -110,4 +110,62 @@ ThrowOutOfMemory(std::string_view Message)
}
#endif
+#if ZEN_PLATFORM_WINDOWS
+bool
+IsOOM(const std::system_error& SystemError)
+{
+ switch (SystemError.code().value())
+ {
+ case ERROR_NOT_ENOUGH_MEMORY:
+ case ERROR_OUTOFMEMORY:
+ case ERROR_PAGEFILE_QUOTA_EXCEEDED:
+ case ERROR_NONPAGED_SYSTEM_RESOURCES:
+ case ERROR_PAGED_SYSTEM_RESOURCES:
+ case ERROR_PAGEFILE_QUOTA:
+ case ERROR_COMMITMENT_LIMIT:
+ return true;
+ default:
+ return false;
+ }
+}
+bool
+IsOOD(const std::system_error& SystemError)
+{
+ switch (SystemError.code().value())
+ {
+ case ERROR_HANDLE_DISK_FULL:
+ case ERROR_DISK_FULL:
+ case ERROR_DISK_RESOURCES_EXHAUSTED:
+ case ERROR_DISK_QUOTA_EXCEEDED:
+ return true;
+ default:
+ return false;
+ }
+}
+#else
+bool
+IsOOM(const std::system_error& SystemError)
+{
+ switch (SystemError.code().value())
+ {
+ case ENOMEM:
+ return true;
+ default:
+ return false;
+ }
+}
+bool
+IsOOD(const std::system_error& SystemError)
+{
+ switch (SystemError.code().value())
+ {
+ case ENOSPC:
+ case EDQUOT:
+ return true;
+ default:
+ return false;
+ }
+}
+#endif
+
} // namespace zen