- methods that return an object should throw an exception on failure (tm)
authorMichael Wallner <mike@php.net>
Fri, 3 Mar 2006 20:19:45 +0000 (20:19 +0000)
committerMichael Wallner <mike@php.net>
Fri, 3 Mar 2006 20:19:45 +0000 (20:19 +0000)
  HttpMessage::getParentMessage() throws HttpMessageException if
  there's no parent message

http_message_object.c

index 4cb201a2e6f21093403b525301c5d36fbc675a2e..c0f5bf006118626abe6577acf8a6b97bf8f46565 100644 (file)
@@ -1127,20 +1127,22 @@ PHP_METHOD(HttpMessage, setHttpVersion)
  * Get parent Message.
  * 
  * Returns the parent HttpMessage on success, or NULL if there's none.
+ *
+ * Throws HttpMessageException.
  */
 PHP_METHOD(HttpMessage, getParentMessage)
 {
-       NO_ARGS;
-
-       IF_RETVAL_USED {
+       SET_EH_THROW_HTTP();
+       NO_ARGS {
                getObject(http_message_object, obj);
 
                if (obj->message->parent) {
                        RETVAL_OBJVAL(obj->parent, 1);
                } else {
-                       RETVAL_NULL();
+                       http_error(HE_WARNING, HTTP_E_MESSAGE, "HttpMessage does not have a parent message");
                }
        }
+       SET_EH_NORMAL();
 }
 /* }}} */