nucleartide / ember-elm

Write Elm in your Ember app
https://medium.com/@nucleartide/introducing-ember-elm-d47f2af73aff
Other
55 stars 7 forks source link

Use 'report' argument to get elm errors as JSON #30

Closed ondrejsevcik closed 5 years ago

ondrejsevcik commented 6 years ago

There is an report argument on elm make.

    --report=<report-type>
        You can say --report=json to get error messages as JSON. This is only
        really useful if you are an editor plugin. Humans should avoid it!

It should simplify error handling and allow for nice error messages.

ondrejsevcik commented 5 years ago

Okay, I did some research and it seems that it's mainly for editor plugins.

It give a following output

{
   "type":"compile-errors",
   "errors":[
      {
         "path":"~/ember-elm/tmp/elm_compiler-input_base_path-nEJC1ryT.tmp/dummy/elm-modules/Hello.elm",
         "name":"Hello",
         "problems":[
            {
               "title":"TOO MANY ARGS",
               "region":{
                  "start":{
                     "line":7,
                     "column":5
                  },
                  "end":{
                     "line":7,
                     "column":9
                  }
               },
               "message":[
                  "The `text` function expects 1 argument, but it got 2 instead.\n\n7|     text \"hello world\" 1\n       ",
                  {
                     "bold":false,
                     "underline":false,
                     "color":"red",
                     "string":"^^^^"
                  },
                  "\nAre there any missing commas? Or missing parentheses?"
               ]
            }
         ]
      }
   ]
}

I think we're fine with basic text output as it is already nicely formatted and gives good enough overview where the issue is.