gpt4 book ai didi

error-handling - 如何在LotusScript中捕获错误消息

转载 作者:行者123 更新时间:2023-12-03 08:32:05 25 4
gpt4 key购买 nike

我想在错误处理程序中捕获错误消息,并在if条件下使用它:

errorhandler:
Print "Error in function TriggerMail -- " & Cstr(Error) & " -- occured at line - " & Cstr(Erl())
MsgBox CStr(Error)
    If CStr(Error) = "Unable to send mail, no match found in Name & Address Book(s)" Then
curdoc.Flag = " Invalid Short name"
Call curdoc.Save(False, True)
end if

我正在使用cstr(Error)获得并进行验证...虽然我的'If'条件为true,但它正在跳过条件。

请纠正我,并告诉我其他方法。

尝试使用错误号仍无法进入if循环
Call doc.Send(False, False)

If Str(Err) = "4294" Then
curdoc.Flag = " Invalid Short name"
curdoc.defaulterSLACount = CInt(defaultCount)
Call curdoc.Save(False, True)
Else
''---------------------------------------------------------------------------------------------------------------
' Flags set in the week doc of the defaulter for reference
'curdoc.Flag = "Mail Sent Successfully"
curdoc.SentTo = doc.sendTo
curdoc.CopiedTo = doc.CopyTo
curdoc.SentOn = Cstr(Now)
curdoc.defaulterSLACount = Cint(defaultCount)

Call curdoc.Save(False, True)
End If

Else

curdoc.Flag = "Mail Not Sent"
curdoc.defaulterSLACount = Cint(defaultCount)
Call curdoc.Save(False, True)

End If ' -------------------- DefaulterCount If Check ends here

Exit Function

errorhandler:
Print "Error in function TriggerMail -- " & Cstr(Error) & " -- occured at line - " & Cstr(Erl())
MsgBox Str(Err)

Resume Next

最佳答案

建议您不要使用Error,而是使用 Err statement 来获取错误号,并根据错误号执行操作。

更新:

您需要在错误处理程序中编写条件If Str(Err) = "4294" Then

errorhandler:

If Str(Err) = "4294" Then
curdoc.Flag = " Invalid Short name"
curdoc.defaulterSLACount = CInt(defaultCount)
Call curdoc.Save(False, True)
Else

或者您可以编写代码来专门处理 4294的错误
... 
...
...
On Error 4294 goto AmbiguousError doc.send(True)
...
...
...
Exit sub

AmbiguousError:
Set namesdb= session.getdatabase(db.server, "names.nsf")
Set Persondoc= namesdb.getview("($Users)").getdocumentbykey(docmail.SendTo(0))
docMail.SendTo = Persondoc.fullname(0) & "@" & Persondoc.MailDomain(0)
Call docMail.Send(True)
Resume next
End sub

上面的代码段来自此 TechNote

关于error-handling - 如何在LotusScript中捕获错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20327816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com