我看到Sublime Pretty Yaml
代码使用pyyaml
,
try:
obj = yaml.load(self.view.substr(selection))
....
except:
...
#show error in statusbar
所以pyyaml可能会例外。如何查看,上面的代码中用什么示例文件来查看错误?
答案 0 :(得分:2)
我不确定我理解你的问题。如果您要查找例外文本,请按the example in the pyyaml docs。换句话说,继续你的例子:
try:
obj = yaml.load(self.view.substr(selection))
....
except yaml.YAMLError, exc:
if hasattr(exc, 'problem_mark'):
mark = exc.problem_mark
errormessage = "Error position: (%s:%s)" % (mark.line+1, mark.column+1)
else:
errormessage = "Something else went wrong with ..."
# do whatever you want with errormessage