elm / error-message-catalog

A catalog of broken Elm programs / data to improve error messages
BSD 3-Clause "New" or "Revised" License
173 stars 17 forks source link

Confusing error message when constructing a line-charts axis #291

Open dbrgn opened 5 years ago

dbrgn commented 5 years ago

(Sorry if the terminology is sometimes a bit off, I'm still quite new to Elm.)

With the line-charts library and this module:

module Testcase exposing (makeAxis)

import LineChart.Axis as Axis
import LineChart.Axis.Line as AxisLine
import LineChart.Axis.Range as Range
import LineChart.Axis.Ticks as Ticks
import LineChart.Axis.Title as Title
import Time

type alias Measurement =
    { id : Int
    , sensorId : Maybe Int
    , temperature : Float
    , createdAt : Time.Posix
    }

makeAxis : Axis.Config Measurement msg
makeAxis =
    Axis.custom
        { title = Title.default ""
        , variable = Just << Time.posixToMillis << .createdAt
        , pixels = 500
        , range = Range.padded 20 20
        , axisLine = AxisLine.none
        , ticks = Ticks.time Time.utc 10
        }

...I get this error message:

img

It took me quite long to find out that the problem was that Time.posixToMillis returns an integer while the value should be a float. Changing the line to variable = Just << toFloat << Time.posixToMillis << .createdAt helped.

Issues:

And not related to the error message: