~ben/yesod-text-markdown

a0fec5dcb7038ed84f82413da92f5b135eeae485 — Arash Rouhani 7 years ago 7d7e35b + 09b6eac
Merge pull request #13 from MaxGabriel/improveErrorMessage

Give a better error message when the markdown is of the wrong type
1 files changed, 2 insertions(+), 2 deletions(-)

M Yesod/Text/Markdown.hs
M Yesod/Text/Markdown.hs => Yesod/Text/Markdown.hs +2 -2
@@ 11,7 11,7 @@ import Yesod.Form
import Yesod.Core (HandlerSite)
import Yesod.Core.Widget
import Yesod.Persist
import Data.Text (Text)
import Data.Text (Text, pack)
import Data.Text.Lazy (toStrict, fromStrict)
import Text.Markdown (Markdown (Markdown))
import Database.Persist.Sql


@@ 22,7 22,7 @@ import Data.Aeson
instance PersistField Markdown where
  toPersistValue (Markdown t) = PersistText $ toStrict t
  fromPersistValue (PersistText t) = Right $ Markdown $ fromStrict t
  fromPersistValue _ = Left "Not a PersistText value"
  fromPersistValue wrongValue = Left $ pack $ "Yesod.Text.Markdown: When attempting to create Markdown from a PersistValue, received " ++ show wrongValue ++ " when a value of type PersistText was expected."

instance PersistFieldSql Markdown where
    sqlType _ = SqlString