Skip to content

Commit

Permalink
fix(ex/skate/ors): change error type to error tuple with value and lo…
Browse files Browse the repository at this point in the history
…g error in directions formatter
  • Loading branch information
firestack committed Dec 2, 2024
1 parent 3f74359 commit ee13b5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/skate/open_route_service_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ defmodule Skate.OpenRouteServiceAPI do
11 -> :depart
12 -> :keep_left
13 -> :keep_right
_ -> :error
value -> {:error, value}
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule Skate.OpenRouteServiceAPI.DirectionsFormatter.MBTA.English do
@moduledoc """
Formats Directions from Open Route Service into MBTA English specific Directions Shorthand.
"""
require Logger

@doc """
Formats a Open Route Service Direction Instruction Map into
Expand All @@ -18,9 +19,18 @@ defmodule Skate.OpenRouteServiceAPI.DirectionsFormatter.MBTA.English do
# Converts ORS Instructions into string form, or `nil`
# Ignore noisy instructions
defp format_instruction(type, _name, _)
when type in [:goal, :depart, :straight, :error],
when type in [:goal, :depart, :straight],
do: nil

# Ignore type errors
defp format_instruction({:error, value}, _name, attrs) do
Logger.error(
"Received :error, when formatting instruction, value=#{value} ors_attrs=#{inspect(attrs)}"
)

nil
end

# ORS uses `-` as a value when a direction doesn't have a name
# Reject instructions without a name
defp format_instruction(_type, "-", _),
Expand Down

0 comments on commit ee13b5e

Please sign in to comment.