jolicode / slack-php-api

:hash: PHP Slack Client based on the official OpenAPI specification
https://jolicode.github.io/slack-php-api/
MIT License
221 stars 54 forks source link

Example of getting error message? #97

Closed khromov closed 3 years ago

khromov commented 3 years ago

How can I get the error message from response_metadata? All I can see from $e->getMessage() is Slack returned error code "invalid_arguments", but how do I know which arguments?

damienalexandre commented 3 years ago

This library return a custom \JoliCode\Slack\Exception\SlackErrorResponse where you get:

Slack does not gives more informations.

From the documentation:

invalid_arguments | The method was either called with invalid arguments or some detail about the arguments passed are invalid, which is more likely when using complex arguments like blocks or attachments.

Feel free to reopen this issue if there is something we can do to help, Cheers

s7thamon commented 3 years ago

I'm having this issue as well with dialog.open.

https://api.slack.com/methods/dialog.open

Slack returned error code "validation_errors" but I can't seem to get the response_metadata with the actual message of what the issue is.

$error->getMessage() = "Slack returned error code "validation_errors""
$error->getErrorCode() = "validation_errors"
damienalexandre commented 3 years ago

That's right, the dialog.open endpoint does not allow additional properties (https://github.com/jolicode/slack-php-api/blob/a5381f275082ea9549e04ef4db890614294be9fb/resources/slack-openapi-patched.json#L13950), so we cannot read the response_metadata.messages node in the response from Slack.

Maybe additionalProperties should always be true.

I'm reopening this issue, thanks for your comment.

MatthewHallCom commented 3 years ago

Another example of this is with views.open - a bit of a pain to debug without it

https://api.slack.com/methods/views.open

Added this MR to help solve it https://github.com/jolicode/slack-php-api/pull/125