2013-02-06 30 views
1
[SMTPClient 
    deliverMailFrom: sender 
    to: recipient 
    text: message 
    usingServer: 'mail.google.com'] 
     on: Error 
     do:["Transcript show:'Sumthing went wrong'"]. 

如果SMTPClient引发ErrorTelnetProtocolErrorConnectionTimedOut。 什么是正确的方式来使成绩单显示我的消息?错误处理SMTPClient

回答

3

您可以随时使用在#do参数:块,以获取有关异常信息:

[SMTPClient 
    deliverMailFrom: sender 
    to: recipient 
    text: message 
    usingServer: 'mail.google.com'] 
     on: Error 
     do:[:e | Transcript show: e]. 

的:在#do e参数:块是已经产生错误的实例。