Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Error handling 如何在LotusScript中捕获错误消息_Error Handling_Lotus Notes_Lotusscript - Fatal编程技术网

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

Error handling 如何在LotusScript中捕获错误消息,error-handling,lotus-notes,lotusscript,Error Handling,Lotus Notes,Lotusscript,我想在错误处理程序中捕获错误消息,并在if条件下使用它: errorhandler: Print "Error in function TriggerMail -- " & Cstr(Error) & " -- occured at line - " & Cstr(Erl()) MsgBox CStr(Error) 我使用的是我得到的cstr(错误),并且是有效的。虽然我的“如果”条件为真,但它跳过了条件 请纠正我并告诉我一些替代方法 尝试使用错误号仍无法进入

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

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

我使用的是我得到的cstr(错误),并且是有效的。虽然我的“如果”条件为真,但它跳过了条件

请纠正我并告诉我一些替代方法

尝试使用错误号仍无法进入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
,我建议您使用获取错误号,并根据它执行操作

更新:

如果Str(Err)=“4294”,则需要在错误处理程序中写入条件

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 

上面的代码片段取自此更好地使用On Error语句,因为它是要使用的:

On Error number Goto handler

在函数开始时,您已经可以指定捕获错误的方式。

如果Str(Err)=“4294”,那么curdoc.Flag=“Invalid Short name”curdoc.defaulterSLACount=CInt(defaultCount)调用curdoc.Save(False,True)…我使用了Err,但仍然无法进入If loopCheck,检查代码是否真的抛出错误?也可能是您在比较之前将
err
转换为字符串的原因?是的,我已删除str并尝试仅使用err,但它仍然不起作用。如果我检查代码,它将返回错误处理程序。只是检查了更新的代码。条件
如果Str(Err)=“4294”,那么
应该进入错误处理程序。借助此technote Call doc。发送(False,False)不会发送到错误处理程序,尽管'to'短id不正确,因为'CC'和'BCC'是正确的。但我的要求是,如果“to”短id错误,它不应该向任何人发送邮件。我正在doc.SendTo=curdoc.empShortID(0)中获取“To”值…请告诉我如何才能做到这一点。
On Error number Goto handler