Skip to content

Commit

Permalink
Improved error messages in examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesiarmes committed Jan 22, 2017
1 parent e61c16e commit 59ad8ce
Show file tree
Hide file tree
Showing 28 changed files with 115 additions and 59 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions examples/contact/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/contact/describe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 6 additions & 2 deletions examples/contact/find.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 6 additions & 2 deletions examples/contact/set-photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/contact/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 6 additions & 2 deletions examples/event/cancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
5 changes: 3 additions & 2 deletions examples/event/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 6 additions & 2 deletions examples/event/find.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 3 additions & 5 deletions examples/event/sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/event/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/folder/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/folder/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
5 changes: 3 additions & 2 deletions examples/folder/find.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 6 additions & 2 deletions examples/message/add-attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/message/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/message/describe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 6 additions & 2 deletions examples/message/find.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
13 changes: 9 additions & 4 deletions examples/message/get-attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 6 additions & 2 deletions examples/message/paging.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/message/reply-all.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/message/send.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/system/timezone-definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/user/category-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions examples/user/free-busy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/user/get-configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions examples/user/meeting-suggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/user/update-configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 59ad8ce

Please sign in to comment.