achillean / shodan-python

The official Python library for Shodan
https://developer.shodan.io
Other
2.47k stars 552 forks source link

APIError support for Status Code #213

Open birkagal opened 3 months ago

birkagal commented 3 months ago

Hey there. When using this client, I found this weird behavoiur that the raised APIError contain only a spesific string for every type of error (502, 401 etc) and for others (like 404, which is pretty common..) it just add the text from the http response.. Which again is a very spesific string.

A much better approach is to also add the status code itself to the exception, and whenever the user catch the exception he can check for example if the status is 404 instead of checking that spesific string (which is what I'm currently doing 😃 ) .

So in short, I think we should add support for HTTP Status codes inside the APIError, whenever its appropiate. There are cases we use APIError not when there is an actual HTTPError, so status_code can be None.

Rajpatel143 commented 3 months ago

I'm really sry. My frnd using is. I dnt understand that. I'm really sorry for trouble. Plz I'm sry.

On Fri, 17 May, 2024, 11:42 am Gal Birka, @.***> wrote:

Hey there. When using this client, I found this weird behavoiur that the raised APIError contain only a spesific string for every type of error (502, 401 etc) and for others (like 404, which is pretty common..) it just add the text from the http response.. Which again is a very spesific string.

A much better approach is to also add the status code itself to the exception, and whenever the user catch the exception he can check for example if the status is 404 instead of checking that spesific string (which is what I'm currently doing 😃 ) .

So in short, I think we should add support for HTTP Status codes inside the APIError, whenever its appropiate. There are cases we use APIError not when there is an actual HTTPError, so status_code can be None.

— Reply to this email directly, view it on GitHub https://github.com/achillean/shodan-python/issues/213, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4U6ZMUQJOSAPKHUA2RON33ZCWNTBAVCNFSM6AAAAABH3QDOVOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMYDCOJQGM4DONI . You are receiving this because you are subscribed to this thread.Message ID: @.***>