除了没有从C sprintf捕获错误

时间:2015-03-11 14:39:14

标签: python error-handling except

在python中,我有一个模块中的函数,它给出了一个错误:

ExecutiveRMS-Error: Atom counts between selection sets don't match (20 != 0).

我试着抓住这样的错误:

try:
    # so this raises the error noted above
    pymol.cmd.pair_fit(*fit_args)
except:
    print("Error message not printed")

但这似乎不起作用,可能是因为它不是例外。

错误消息在C中生成,如下所示:

sprintf(buffer, "Atom counts between selection sets don't match (%d != %d).",
          op1.nvv1, op2.nvv1);
ErrMessage(G, "ExecutiveRMS", buffer);
int ErrMessage(MSKContext * G, const char *where, const char *what)
{
  fprintf(stderr, "%s-Error: %s\n", where, what);
  return (0);
}

如何捕获错误消息,就像使用try except一样?

0 个答案:

没有答案