src/ai/api/ai_error.hpp
branchnoai
changeset 9868 3998f2e73dda
parent 9867 b7d9ffe24f81
child 9871 dfafb0cf20ee
--- a/src/ai/api/ai_error.hpp	Sun Apr 06 12:26:40 2008 +0000
+++ b/src/ai/api/ai_error.hpp	Sun Apr 06 14:12:19 2008 +0000
@@ -9,6 +9,17 @@
 #include <map>
 
 /**
+ * Helper to write precondition enforcers for the AI API in an abbreviated manner.
+ * @param returnval The value to return on failure.
+ * @param condition The condition that must be obeyed.
+ */
+#define EnforcePrecondition(returnval, condition)               \
+	if (!(condition)) {                                           \
+		AIObject::SetLastError(AIError::ERR_PRECONDITION_FAILED);   \
+		return returnval;                                           \
+	}
+
+/**
  * Class that handles all error related functions.
  */
 class AIError : public AIObject {