taxjar / vat_check

Validate EU VAT numbers the easy way with VIES!
23 stars 16 forks source link

rescue Savon::HTTPError also #2

Open aiomaster opened 5 years ago

aiomaster commented 5 years ago

Hi,

we use this gem in production and sometimes it failes, cause the VIES service answers with some garbage leading to raise a Savon::HTTPError which is not handled by this gem.

I would suggest to add this error next to this line: https://github.com/taxjar/vat_check/blob/6ddf83c57f74c21b62914551d8920b2dd9fffbbb/lib/vat_check/requests.rb#L11

What do you think?

Here is an example failure response of such a request:

HTTP error (307): <HTML><HEAD>
<TITLE>Network Error</TITLE>
</HEAD>
<BODY>
<FONT face="Helvetica">
<big><strong></strong></big><BR>
</FONT>
<blockquote>
<TABLE border=0 cellPadding=1 width="80%">
<TR><TD>
<FONT face="Helvetica">
<big>Network Error (tcp_error)</big>
<BR>
<BR>
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
A communication error occurred: ""
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica" SIZE=2>
<BR>
For assistance, contact your network support team.
</FONT>
</TD></TR>
</TABLE>
</blockquote>
</FONT>
</BODY></HTML>