karver icon indicating copy to clipboard operation
karver copied to clipboard

make `renderTemplate` total

Open ibotty opened this issue 10 years ago • 2 comments

right now a non-existent include raises an error and parse errors or lookup errors in the context will just render nonsensical text without the calling application being aware of it.

i would need renderTemplate to return Either KarverError Text with a suitable data KarverError = InvalidTemplate LineNo ColumnNo Text | NoSuchInclude Text | ....

i propose the following change to renderTemplate, so that the current behavior is still possible. add another argument to renderTemplate that decides what to do. e.g. renderTemplate :: (KarverError -> Either a Text) -> HashMap Text Value -> Text -> Either a Text.

what do you think?

ibotty avatar Jun 03 '14 09:06 ibotty

see my branch https://github.com/ibotty/karver/tree/total-renderTemplate for one approach requiring a new transformers release.

ibotty avatar Jun 03 '14 14:06 ibotty

Yes I do think that karver need some error handling, and for that reason I will leave this issue open. I'm not going to worry that much about it until I get more of the features of the actual templating part complete.

sourrust avatar Jun 07 '14 04:06 sourrust