pipedrive icon indicating copy to clipboard operation
pipedrive copied to clipboard

Verbose info for logging exception reasons

Open profluck opened this issue 3 years ago • 2 comments

HI :) pipedrive-issue pipedrive-issue-2

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

profluck avatar Nov 12 '21 09:11 profluck

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

IsraelOrtuno avatar Nov 12 '21 11:11 IsraelOrtuno

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);
}

profluck avatar Nov 12 '21 17:11 profluck