diff options
author | Jared Norman <jared@super.gd> | 2019-01-21 20:57:29 -0800 |
---|---|---|
committer | Jared Norman <jared@super.gd> | 2019-01-21 21:08:50 -0800 |
commit | 40b63f8f069b6d869619bbfcb1554a7e7cbcbe57 (patch) | |
tree | 32a576e4f61e59a36111912b232622fd4f094780 /lib | |
parent | d5b84c70cfad6bcb98bee422ce2865dbf8ae386f (diff) |
Handle errors gracefully
Diffstat (limited to 'lib')
-rw-r--r-- | lib/super_good/solidus_taxjar/tax_calculator.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/super_good/solidus_taxjar/tax_calculator.rb b/lib/super_good/solidus_taxjar/tax_calculator.rb index d683cf6..474f762 100644 --- a/lib/super_good/solidus_taxjar/tax_calculator.rb +++ b/lib/super_good/solidus_taxjar/tax_calculator.rb @@ -1,6 +1,11 @@ module SuperGood module SolidusTaxJar class TaxCalculator + class_attribute :exception_handler + self.exception_handler = ->(e) { + Rails.logger.error "An error occurred while fetching TaxJar tax rates - #{e}: #{e.message}" + } + def self.default_api ::SuperGood::SolidusTaxJar::API.new end @@ -22,6 +27,9 @@ module SuperGood shipment_taxes: shipment_taxes ) end + rescue StandardError => e + exception_handler.(e) + no_tax end private |