Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error handling for Browser #894

Open
mostlyobvious opened this issue Dec 10, 2020 · 0 comments
Open

Better error handling for Browser #894

mostlyobvious opened this issue Dec 10, 2020 · 0 comments
Labels

Comments

@mostlyobvious
Copy link
Member

mostlyobvious commented Dec 10, 2020

Consider following scenario:

  • broken events JSON from backend (i.e. missing timestamp key in metadata, i.e. due to misconfigured Event class like Ruby Event Store Browser not loading events because of nil error #762)

    {
      "data": [
          {
              "id": "c6fcd01d-b708-46a7-b712-18783cc6e880",
              "type": "events",
              "attributes": {
                  "event_type": "DummyEvent",
                  "data": {
                      "some_integer_attribute": 42,
                      "some_string_attribute": "foobar",
                      "some_float_attribute": 3.14
                  },
                  "metadata": {},
                  "correlation_stream_name": "$by_correlation_id_469904c5-46ee-43a3-857f-16a455cfe337",
                  "causation_stream_name": "$by_causation_id_c6fcd01d-b708-46a7-b712-18783cc6e880",
                  "type_stream_name": "$by_type_DummyEvent",
                  "parent_event_id": null
              }
          }
    ]
  • event decoder expecting timestamp to be present and generating Err on lack of it

    eventDecoder_ : Decoder Event
    eventDecoder_ =
        succeed Event
            |> requiredAt [ "attributes", "event_type" ] string
            |> requiredAt [ "id" ] string
            |> requiredAt [ "attributes", "metadata", "timestamp" ] Iso8601.decoder
            |> requiredAt [ "attributes", "data" ] (value |> Json.Decode.map (encode 2))
            |> requiredAt [ "attributes", "metadata" ] (value |> Json.Decode.map (encode 2))
            |> optionalAt [ "attributes", "correlation_stream_name" ] (maybe string) Nothing
            |> optionalAt [ "attributes", "causation_stream_name" ] (maybe string) Nothing
            |> requiredAt [ "attributes", "type_stream_name" ] string
            |> optionalAt [ "attributes", "parent_event_id" ] (maybe string) Nothing
    ▾GotShowStreamMsg EventsFetched …
    ▾0 = Err BadBody …
     0 = "Problem with the value at json.data[0].attributes.metadata:\n\n {}\n\nExpecting an OBJECT with a field named `timestamp`"
    
  • handling of Err in update

            EventsFetched (Err errorMessage) ->
              ( model, Cmd.none )
  • view on initial data being optimistic

    renderResults baseUrl events =
       case events of
            [] ->
                p [ class "results__empty" ] [ text "No items" ]
    

We end up with empty page suggesting no items like no error ever happened. Backend logs show to clue either -- all is good there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

1 participant