diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f8d396 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +.deps +.libs/ +Makefile +Makefile.fragments +Makefile.global +Makefile.objects +acinclude.m4 +aclocal.m4 +autom4te.cache/ +config.guess +config.h +config.h.in +config.log +config.nice +config.status +config.sub +configure +configure.in +install-sh +libtool +ltmain.sh +missing +mkinstalldirs +modules/ +php_stomp.lo +run-tests.php +stomp.la +stomp.lo diff --git a/php_stomp.c b/php_stomp.c index d31d420..2d574a5 100755 --- a/php_stomp.c +++ b/php_stomp.c @@ -538,11 +538,22 @@ PHP_FUNCTION(stomp_connect) stomp_send(stomp, &frame TSRMLS_CC); CLEAR_FRAME(frame); - + /* Retreive Response */ res = stomp_read_frame(stomp); if (NULL == res) { STOMP_ERROR(0, PHP_STOMP_ERR_SERVER_NOT_RESPONDING); + } else if (0 == strncmp("ERROR", res->command, sizeof("ERROR") - 1)) { + char *error_msg = NULL; + if (zend_hash_find(res->headers, "message", sizeof("message"), (void **)&error_msg) == SUCCESS) { + zval *excobj = zend_throw_exception_ex(stomp_ce_exception, 0 TSRMLS_CC, error_msg); + if (res->body) { + zend_update_property_string(stomp_ce_exception, excobj, "details", sizeof("details")-1, (char *) res->body TSRMLS_CC); + } + + stomp_free_frame(res); + RETURN_FALSE; + } } else if (0 != strncmp("CONNECTED", res->command, sizeof("CONNECTED")-1)) { if (stomp->error) { STOMP_ERROR_DETAILS(stomp->errnum, stomp->error, stomp->error_details); diff --git a/tests/003-connect/003.phpt b/tests/003-connect/003.phpt new file mode 100644 index 0000000..0ac0db2 --- /dev/null +++ b/tests/003-connect/003.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test stomp_connect() - Test error on CONNECT +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(14) "StompException"