IsraelOrtuno / pipedrive

Complete Pipedrive API client for PHP
MIT License
166 stars 58 forks source link

Verbose info for logging exception reasons #117

Closed profluck closed 1 year ago

profluck commented 2 years ago

HI :) pipedrive-issue pipedrive-issue-2

It would be great to show an additional reason for the error for quick debugging. Thanks

IsraelOrtuno commented 2 years ago

You are right but this seems like a breaking change. What's your proposal?

profluck commented 2 years ago

As a quick solution concatenate error message with additional error info. Official PipeDrive link on it: https://pipedrive.readme.io/docs/core-api-concepts-responses

/**
* Throws PipedriveException with message depending on content.
* @see https://pipedrive.readme.io/docs/core-api-concepts-responses
*
* @param \stdClass $content
*/
protected function throwPipedriveException($content)
{
    if (!isset($content->error, $content->error_info)) {
        throw new PipedriveException('Error unknown.');
    }

    $errorMessage = $content->error . '. Info: ' . $content->error_info;

    throw new PipedriveException($errorMessage);
}