jpetrucciani / hubspot3

python3.6+ hubspot client based on hapipy, but modified to use the newer endpoints and non-legacy python
MIT License
147 stars 73 forks source link

Add HubSpot's error message on top of HubspotError string representation #13

Closed artemgordinskiy closed 5 years ago

artemgordinskiy commented 5 years ago

HubspotError currently uses the following template for generating its string representation, which contains a lot of useful debugging info:

---- request ----
{method} {host}{url}, [timeout={timeout}]

---- body ----
{body}

---- headers ----
{headers}

---- result ----
{result_status}

---- body -----
{result_body}

---- headers -----
{result_headers}

---- reason ----
{result_reason}

---- trigger error ----
{error}

However I've noticed that when using error-tracking services like Sentry, the first line of the error message is usually used as the issue title, which in this case is ---- request ---- . This leads to all of HubSpot errors being merged into one issue, making them pretty hard to track and work with.

I suggest adding an error message returned from HubSpot as the first line of __str__/__unicode__, which would solve this problem.

My implementation expects HubSpot's error responses to be returned in the following format (which seems to be the one they're using):

{
  "status": "error",
  "message": "Property values were not valid",
  ...
}

Haven't added any tests yet, just want to make sure it makes sense to you first.

jpetrucciani commented 5 years ago

Makes sense to me! Sounds like a great fix for error trackers

artemgordinskiy commented 5 years ago

@jpetrucciani Great! Cleaned up a bit and added some tests.

artemgordinskiy commented 5 years ago

@jpetrucciani Thanks for the quick merge! Could you push a new release out please? Any time this week would be great, so no rush :)

jpetrucciani commented 5 years ago

For sure! Sorry about that - meant to do that last night, but GitHub was being a bit odd. I'm surprised that it did actually merge! It kept throwing error messages when I was trying to last night. I'll get a release out soon!

jpetrucciani commented 5 years ago

Interesting - none of my Travis builds are working currently. I think it's due to the fact that GitHub is currently having some issues. I'll keep an eye out for when it's fixed, then I'll make sure Travis deploys it for us!

artemgordinskiy commented 5 years ago

My bad, forgot GitHub is broken today 😄 Thanks for checking!

jpetrucciani commented 5 years ago

Just confirmed that webhooks are back to a working state, and the newest release is now live! https://pypi.org/project/hubspot3/

artemgordinskiy commented 5 years ago

Awesome, thanks!