diff --git a/CHANGELOG.md b/CHANGELOG.md index e25a3130..f1c4b59b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Fixed Exchange 2007 version parsing in autodiscovery. - Fixed event title in event/create example. - Fixed capitalization of URL property on PushSubscriptionRequestType. +- Improved error messages in examples. ## 1.0.0-beta.2 - 2017-01-12 diff --git a/examples/contact/create.php b/examples/contact/create.php index 1ce96bd4..d8a23ff3 100644 --- a/examples/contact/create.php +++ b/examples/contact/create.php @@ -86,8 +86,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Contact failed to create with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Contact failed to create with \"$code: $message\"\n"); continue; } diff --git a/examples/contact/describe.php b/examples/contact/describe.php index 7730cd30..f529925b 100644 --- a/examples/contact/describe.php +++ b/examples/contact/describe.php @@ -46,8 +46,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to get contact with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Failed to get contact with \"$code: $message\"\n"); continue; } diff --git a/examples/contact/find.php b/examples/contact/find.php index bbf2ddd5..bf0ae6fd 100644 --- a/examples/contact/find.php +++ b/examples/contact/find.php @@ -37,8 +37,12 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to search for contacts with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite( + STDERR, + "Failed to search for contacts with \"$code: $message\"\n" + ); continue; } diff --git a/examples/contact/set-photo.php b/examples/contact/set-photo.php index fa78709c..d6329c82 100644 --- a/examples/contact/set-photo.php +++ b/examples/contact/set-photo.php @@ -55,8 +55,12 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to create attachment with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite( + STDERR, + "Failed to create attachment with \"$code: $message\"\n" + ); continue; } diff --git a/examples/contact/update.php b/examples/contact/update.php index cb4d98f6..6ef35df1 100644 --- a/examples/contact/update.php +++ b/examples/contact/update.php @@ -85,8 +85,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to update contact with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Failed to update contact with \"$code: $message\"\n"); continue; } diff --git a/examples/event/cancel.php b/examples/event/cancel.php index 99ed84af..6e75fb37 100644 --- a/examples/event/cancel.php +++ b/examples/event/cancel.php @@ -47,8 +47,12 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Cancellation failed to create with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite( + STDERR, + "Cancellation failed to create with \"$code: $message\"\n" + ); continue; } } diff --git a/examples/event/create.php b/examples/event/create.php index 1751111b..6f082305 100644 --- a/examples/event/create.php +++ b/examples/event/create.php @@ -77,8 +77,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Event failed to create with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Event failed to create with \"$code: $message\"\n"); continue; } diff --git a/examples/event/find.php b/examples/event/find.php index 731c2315..8069d49d 100644 --- a/examples/event/find.php +++ b/examples/event/find.php @@ -51,8 +51,12 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to search for events with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite( + STDERR, + "Failed to search for events with \"$code: $message\"\n" + ); continue; } diff --git a/examples/event/sync.php b/examples/event/sync.php index 1fff691e..607365d1 100644 --- a/examples/event/sync.php +++ b/examples/event/sync.php @@ -55,11 +55,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to sync folder with \"$message\"\n"); - - $soap = $client->getClient(); - $lr = $soap->__getLastRequest(); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Failed to sync folder with \"$code: $message\"\n"); continue; } diff --git a/examples/event/update.php b/examples/event/update.php index 77783526..de5d6dfc 100644 --- a/examples/event/update.php +++ b/examples/event/update.php @@ -80,8 +80,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to update event with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Failed to update event with \"$code: $message\"\n"); continue; } diff --git a/examples/folder/create.php b/examples/folder/create.php index 8e5f1357..b32f2002 100644 --- a/examples/folder/create.php +++ b/examples/folder/create.php @@ -53,8 +53,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Folder failed to create with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Folder failed to create with \"$code: $message\"\n"); continue; } diff --git a/examples/folder/delete.php b/examples/folder/delete.php index e7eaa8a5..245a914d 100644 --- a/examples/folder/delete.php +++ b/examples/folder/delete.php @@ -47,8 +47,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Folder failed to delete with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Folder failed to delete with \"$code: $message\"\n"); continue; } } diff --git a/examples/folder/find.php b/examples/folder/find.php index f188d637..457c0c0e 100644 --- a/examples/folder/find.php +++ b/examples/folder/find.php @@ -66,8 +66,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to find folders with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Failed to find folders with \"$code: $message\"\n"); continue; } diff --git a/examples/message/add-attachment.php b/examples/message/add-attachment.php index fd67d2ee..35c161ba 100644 --- a/examples/message/add-attachment.php +++ b/examples/message/add-attachment.php @@ -55,8 +55,12 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to create attachment with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite( + STDERR, + "Failed to create attachment with \"$code: $message\"\n" + ); continue; } diff --git a/examples/message/create.php b/examples/message/create.php index eaa6c0be..433c2c9c 100644 --- a/examples/message/create.php +++ b/examples/message/create.php @@ -78,8 +78,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Message failed to create with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Message failed to create with \"$code: $message\"\n"); continue; } diff --git a/examples/message/describe.php b/examples/message/describe.php index c1345d45..3bf02e1c 100644 --- a/examples/message/describe.php +++ b/examples/message/describe.php @@ -59,8 +59,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to get message with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Failed to get message with \"$code: $message\"\n"); continue; } diff --git a/examples/message/find.php b/examples/message/find.php index 8000e76c..c22514ca 100644 --- a/examples/message/find.php +++ b/examples/message/find.php @@ -77,8 +77,12 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to search for messages with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite( + STDERR, + "Failed to search for messages with \"$code: $message\"\n" + ); continue; } diff --git a/examples/message/get-attachments.php b/examples/message/get-attachments.php index 9726926e..0b8f1af8 100644 --- a/examples/message/get-attachments.php +++ b/examples/message/get-attachments.php @@ -63,8 +63,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to get message with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Failed to get message with \"$code: $message\"\n"); continue; } @@ -104,8 +105,12 @@ // Make sure the request succeeded. if ($attachment_response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $attachment_response_message->ResponseCode; - fwrite(STDERR, "Failed to get attachment with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite( + STDERR, + "Failed to get attachment with \"$code: $message\"\n" + ); continue; } diff --git a/examples/message/paging.php b/examples/message/paging.php index 2822721a..851d2175 100644 --- a/examples/message/paging.php +++ b/examples/message/paging.php @@ -64,8 +64,12 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to search for messages with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite( + STDERR, + "Failed to search for messages with \"$code: $message\"\n" + ); continue; } diff --git a/examples/message/reply-all.php b/examples/message/reply-all.php index 3f9b10cb..b5950182 100644 --- a/examples/message/reply-all.php +++ b/examples/message/reply-all.php @@ -54,8 +54,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Reply failed to create with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Reply failed to create with \"$code: $message\"\n"); continue; } diff --git a/examples/message/send.php b/examples/message/send.php index d534d659..3c188419 100644 --- a/examples/message/send.php +++ b/examples/message/send.php @@ -55,8 +55,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Message failed to send with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Message failed to send with \"$code: $message\"\n"); continue; } diff --git a/examples/system/timezone-definitions.php b/examples/system/timezone-definitions.php index e9bc08b0..55d1db29 100644 --- a/examples/system/timezone-definitions.php +++ b/examples/system/timezone-definitions.php @@ -40,8 +40,9 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to get timezones with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite(STDERR, "Failed to get timezones with \"$code: $message\"\n"); continue; } diff --git a/examples/user/category-list.php b/examples/user/category-list.php index 7b7ee971..de2b309e 100644 --- a/examples/user/category-list.php +++ b/examples/user/category-list.php @@ -42,10 +42,11 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; fwrite( STDERR, - "Failed to get User Configuration with \"$message\"\n" + "Failed to get User Configuration with \"$code: $message\"\n" ); continue; } diff --git a/examples/user/free-busy.php b/examples/user/free-busy.php index 0b9c2f27..b37b529b 100644 --- a/examples/user/free-busy.php +++ b/examples/user/free-busy.php @@ -67,8 +67,12 @@ // Make sure the request succeeded. $response_message = $availability->ResponseMessage; if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to get user availability with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite( + STDERR, + "Failed to get user availability with \"$code: $message\"\n" + ); continue; } diff --git a/examples/user/get-configuration.php b/examples/user/get-configuration.php index a5546093..e9403235 100644 --- a/examples/user/get-configuration.php +++ b/examples/user/get-configuration.php @@ -41,10 +41,11 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; fwrite( STDERR, - "Failed to get User Configuration with \"$message\"\n" + "Failed to get User Configuration with \"$code: $message\"\n" ); continue; } diff --git a/examples/user/meeting-suggestions.php b/examples/user/meeting-suggestions.php index 6976c5d8..4d47dab6 100644 --- a/examples/user/meeting-suggestions.php +++ b/examples/user/meeting-suggestions.php @@ -72,8 +72,12 @@ // Make sure the request succeeded. $response_message = $response->SuggestionsResponse->ResponseMessage; if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; - fwrite(STDERR, "Failed to get user availability with \"$message\"\n"); + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; + fwrite( + STDERR, + "Failed to get user availability with \"$code: $message\"\n" + ); exit; } diff --git a/examples/user/update-configuration.php b/examples/user/update-configuration.php index 0346b5b1..6c83f623 100644 --- a/examples/user/update-configuration.php +++ b/examples/user/update-configuration.php @@ -101,10 +101,11 @@ foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { - $message = $response_message->ResponseCode; + $code = $response_message->ResponseCode; + $message = $response_message->MessageText; fwrite( STDERR, - "User Configuration failed to update with \"$message\"\n" + "User Configuration failed to update with \"$code: $message\"\n" ); continue; }