dhall - 如何在 extractError 中获取更多上下文?
问题描述
我有这个用于解码类型良好的Path
s
pathDecoder f opts =
Decoder
{ extract = extractPath
, expected = expectedPath
}
where
filePathDecoder :: Decoder FilePath
filePathDecoder = autoWith opts
extractPath expression =
case extract filePathDecoder expression of
Success x -> case f x of
Left exception -> Dhall.extractError (T.pack $ show exception)
Right path -> Success path
Failure e -> Failure e
expectedPath = expected filePathDecoder
instance FromDhall (Path Abs Dir) where
autoWith options = pathDecoder parseAbsDir options
这有效,但在失败时不会给出非常有用的错误。
Error: Failed extraction
The expression type-checked successfully but the transformation to the target
type failed with the following error:
InvalidAbsDir "foo/"
这个值可以在任何地方,所以我希望能够看到提取失败的字段名。这是可能的还是我在这里有错误的想法?
解决方案
推荐阅读
- javascript - 仅显示 while 循环中 JavaScript 的最后一个值
- c++ - 如何正确跳过 unicode (UTF-8) 字符?
- java - ")" 匹配括号的正则表达式
- asp.net-mvc - 如何将一个表的主键保存到 ASP.NET MVC 中的另一个表中
- python - 追加和替换一个字符串中的对象
- java - 允许交换时的不同字符串
- php - 如何使用foreach循环获取数组值
- c# - 从 C# 中的视图模型中按名称关闭活动窗口?
- node.js - 使用 POST 请求将数据从 Node 服务器发送回 React 客户端
- python - 如何比较句子与关键字位置的想法?