How to read Yesod error messages effectively?

334 Views Asked by At

(newbie alert)

Given the following error message, what's the quickest way to get to the source of the error:

08/Jul/2016:11:39:01 +0530 [Error#yesod-core] expected EPlain but got Nothing for: DerefBranch (DerefIdent (Ident "show")) (DerefString "abcdef") @(yesod_3MCr4WfhviiELXmo3fAaXL:Yesod.Core.Class.Yesod ./Yesod/Core/Class/Yesod.hs:625:5)
GET /
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  Status: 500 Internal Server Error 0.054158s

Handler/Home.hs:38:11:
    No instance for (Text.Julius.ToJavascript String)
      arising from a use of ‘Text.Julius.toJavascript’
    In the second argument of ‘(GHC.Base..)’, namely
      ‘Text.Julius.toJavascript’
    In the second argument of ‘(GHC.Base..)’, namely
      ‘(Text.Julius.unJavascript GHC.Base.. Text.Julius.toJavascript)’
    In the expression:
      Text.Shakespeare.EPlain
      GHC.Base..
        (Text.Julius.unJavascript GHC.Base.. Text.Julius.toJavascript)
Build failure, pausing...

I'm working with a simple scaffolded site (no DB) and have purposely messed up with homepage.julius. In this particular instance I know exactly what the error is, but how can one know just by looking at the error message?

1

There are 1 best solutions below

3
On

After perusing http://hackage.haskell.org/package/shakespeare-2.0.8/docs/Text-Julius.html, it looks like you are trying to embed a plain string in something that wants javascript.

That is usually prevented so that someone can't inject bad code into a page when you are trying to just display a string they've supplied. So just call rawJS on it and it should embed? Or perhaps you are using the wrong interpolation type for the variable you are supplying (@,^, or #). Yesod is particular about that.

This just just a guess as I don't use julius.