maybe icon indicating copy to clipboard operation
maybe copied to clipboard

Handle non-map or non-nil values

Open zberkom opened this issue 6 years ago • 0 comments

I ran into this issue recently on CC. Basically, we had a library that returns :unknown atom keys instead of nil when it can't find a value. For example:

%UAInspector.Result{
  client: %UAInspector.Result.Client{
    engine: "Blink",
    engine_version: :unknown,
    name: "Chrome",
    type: "browser",
    version: "63.0.3239.132"
  },
  device: %UAInspector.Result.Device{
    brand: :unknown,
    model: :unknown,
    type: "desktop"
  },
  os: %UAInspector.Result.OS{
    name: "Mac",
    platform: :unknown,
    version: "10.12.6"
  },
  user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
}

Running maybe(ua.device.model.name) would fail with BadMapError with message "expected a map, got: :unknown"

This PR resolves this issue.

zberkom avatar Feb 05 '18 17:02 zberkom