From 9c442cd66c7d12266ba53e85949f775f6b842d2d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 4 May 2018 12:49:06 +0200 Subject: Move `TomTom::Matrix::RemoteError` to`TomTom::Errors::MatrixRemoteError` I previously tried to correct a circular dependency problem in a057276129b1f62b811743db3b8f867a05241ed3, but that didn't fix it (it was intermittent, and came back). After some wrangling, I've now deduced with some confidence that the problem comes from `RouteWayCostCalculator`, which used `TomTom::Matrix::RemoteError`. From the way it looks, this seems to mess up the Rails autoloader since `tom_tom.rb` will try to load the `Matrix` class from the `TomTom.matrix` call above. Or something. In an attempt to fix the circular dependency error for real this time, move the error class to a completely separate module from `Matrix`, and refer to this when we need to use the error class. Refs #6884 --- lib/tom_tom/matrix.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/tom_tom/matrix.rb') diff --git a/lib/tom_tom/matrix.rb b/lib/tom_tom/matrix.rb index d0b476d84..96518f7cf 100644 --- a/lib/tom_tom/matrix.rb +++ b/lib/tom_tom/matrix.rb @@ -6,8 +6,8 @@ module TomTom # Exceptions: # - # * This raises a `TomTom::Matrix::RemoteError` when the API responds with - # an error. + # * This raises a `TomTom::Errors::MatrixRemoteError` when the API responds + # with an error. def matrix(way_costs) points_with_ids = points_from_way_costs(way_costs) points = points_as_params(points_with_ids) @@ -84,13 +84,14 @@ module TomTom def check_for_error_response(response) if response.status != 200 - raise RemoteError, "status: #{response.status}, body: #{response.body}" + raise TomTom::Errors::MatrixRemoteError, + "status: #{response.status}, body: #{response.body}" end json = JSON.parse(response.body) if json.has_key?('error') - raise RemoteError, + raise TomTom::Errors::MatrixRemoteError, "status: #{response.status}, message: #{json['error']['description']}" end end -- cgit v1.2.3