diff --git a/official/guides/errors-guide/csharp/catch-error.cs b/official/guides/errors-guide/csharp/catch-error.cs index 0160d939..c68ae8af 100644 --- a/official/guides/errors-guide/csharp/catch-error.cs +++ b/official/guides/errors-guide/csharp/catch-error.cs @@ -8,7 +8,7 @@ } await Address.Create(parameters); } -catch (EasyPost.HttpException e) +catch (EasyPost.Exceptions.API.ApiError error) { - Console.Write(e.Code); // ADDRESS.VERIFY.FAILURE + Console.Write(error.Code); // ADDRESS.VERIFY.FAILURE } diff --git a/official/guides/errors-guide/golang/catch-error.go b/official/guides/errors-guide/golang/catch-error.go index bf2e5763..51681b29 100644 --- a/official/guides/errors-guide/golang/catch-error.go +++ b/official/guides/errors-guide/golang/catch-error.go @@ -20,5 +20,7 @@ func main() { }, ) - fmt.Println(err) + if err, ok := err.(*easypost.APIError); ok { + fmt.Println(err.Code) + } } diff --git a/official/guides/errors-guide/java/catch-error.java b/official/guides/errors-guide/java/catch-error.java index ff386763..9b7abce1 100644 --- a/official/guides/errors-guide/java/catch-error.java +++ b/official/guides/errors-guide/java/catch-error.java @@ -3,7 +3,7 @@ import java.util.HashMap; import com.easypost.EasyPost; -import com.easypost.exception.EasyPostException; +import com.easypost.exception.APIException; public class CatchError { public static void main(String[] args) throws EasyPostException { @@ -15,8 +15,8 @@ public static void main(String[] args) throws EasyPostException { address.put("verify_strict", true); Address.create(address); - } catch (EasyPostException e) { - System.err.println(e.getMessage()); + } catch (APIException error) { + System.err.println(error.getCode()); } } } diff --git a/official/guides/errors-guide/node/catch-error.js b/official/guides/errors-guide/node/catch-error.js index 1ca8ef99..f5165d13 100644 --- a/official/guides/errors-guide/node/catch-error.js +++ b/official/guides/errors-guide/node/catch-error.js @@ -3,6 +3,6 @@ const api = new Easypost('{API_KEY}'); api.Address.save({ strict_verify: true, -}).catch((e) => { - console.log(e); +}).catch((error) => { + console.error(error.code); }); diff --git a/official/guides/errors-guide/php/catch-error.php b/official/guides/errors-guide/php/catch-error.php index e41bd1bf..7893da74 100644 --- a/official/guides/errors-guide/php/catch-error.php +++ b/official/guides/errors-guide/php/catch-error.php @@ -1,5 +1,9 @@ + true)); -catch (\EasyPost\Error $e) { - echo $e->ecode; + \EasyPost\Address::create([ + "strict_verify" => true, + ]); +} catch (\EasyPost\Exception\Api\ApiException $error) { + echo $error->code; } diff --git a/official/guides/errors-guide/python/catch-error.py b/official/guides/errors-guide/python/catch-error.py index 682f2a8b..f4f2bba3 100644 --- a/official/guides/errors-guide/python/catch-error.py +++ b/official/guides/errors-guide/python/catch-error.py @@ -2,5 +2,5 @@ try: easypost.Address.create({"strict_verify": True}) -except easypost.Error as e: - print(e.json_body["code"]) +except easypost.errors.api.ApiError as error: + print(error.code) diff --git a/official/guides/errors-guide/ruby/catch-error.rb b/official/guides/errors-guide/ruby/catch-error.rb index 7498513a..efcd5c68 100644 --- a/official/guides/errors-guide/ruby/catch-error.rb +++ b/official/guides/errors-guide/ruby/catch-error.rb @@ -2,6 +2,6 @@ begin Address.create({}, strict_verify: true) -rescue EasyPost::Error => e +rescue EasyPost::Errors::ApiError => e p e.code end