~ihabunek/triglav

ref: 7cbad225e849bdc6e92053a7a08b6945697ed4e4 triglav/lib/triglav/zet/errors.ex -rw-r--r-- 1.6 KiB
7cbad225Ivan Habunek Validate gtfs stop ids populated 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
defmodule Triglav.Zet.Errors do
  alias Triglav.Schemas.Error

  def render(%Error{key: "missing_route_master"}) do
    "Missing route_master relation"
  end

  def render(%Error{key: "multiple_route_masters"}) do
    "Multiple route_master relations"
  end

  def render(%Error{key: "no_relations"}) do
    "No OSM relations found"
  end

  def render(%Error{key: "relation_not_updated_to_ptv2"}) do
    "Relation not updated to [public_transport:version=2]"
  end

  def render(%Error{
        key: "invalid_relation_name",
        params: %{"expected" => expected, "actual" => actual}
      }) do
    "Expected name based on tags: '#{expected}', actual name: '#{actual}"
  end

  def render(%Error{key: "relation_missing_required_tags", params: %{"tags" => tags}}) do
    "Missing required tags: #{Enum.join(tags, ", ")}"
  end

  def render(%Error{key: "relation_contains_unexpected_tags", params: %{"tags" => tags}}) do
    "Unexpected tags: #{Enum.join(tags, ", ")}"
  end

  def render(%Error{key: "relation_missing_gtfs_stop_ids", params: %{"count" => count}}) do
    "Missing gtfs:stop_id tags on #{count} platforms"
  end

  def render(%Error{
        key: "invalid_tag_value",
        params: %{"name" => name, "expected" => expected, "actual" => actual}
      }) do
    if actual do
      "Invalid tag [#{name}=#{actual}], expected [#{name}=#{expected}]"
    else
      "Missing tag [#{name}=#{expected}]"
    end
  end

  def render(%Error{key: "broken_route", params: %{"way_id" => way_id}}) do
    "Broken route starting at way ##{way_id}"
  end

  def render(%Error{key: key}) do
    "FIXME: missing render function for error '#{key}'"
  end
end