Hi Amit:
Thans for your reply.
I am making a unit test to my "try{}" code. So in my "try" it will "throw" errors according logic. So it is correct the code goto the "catch(e){}".
What I want is the standard of the "msgs.appendChild" when error happed. And when the address will be "Quarantine" ?
msgs.appendChild(<message
id={deliveryPart.message.@id}
status="?"
noRetry="true"
log={e.toString()}
failureReason="?"
failureType="?"/>);
And my code is the follow:
for each (var msg in deliveryPart.message)
{
try {
// get the service ID and mediaId
var woaId = NL.XTK.toString(msg.wechatService)
var mediaId = NL.XTK.toString(msg.wechatMedia)
if (woaId == null || woaId == "" || mediaId == null || mediaId == "")
{
throw "Parameter error: woaId = " + woaId + "; mediaId = " + mediaId
}
woaId = woaId.replace(BF_SERVICE_PREFIX, "")
//we saved the address with format "@openid + '@' + [service/@name]"
var address = NL.XTK.toString(msg.@address)
var addrArray = address.split('@', 2)
if (addrArray.length != 2)
continue
var openId = NL.XTK.toString(addrArray[0])
var tmpSubscriptionAccount = NL.XTK.toString(addrArray[1])
var tmpDeliveryAccount = NL.XTK.toString(msg.wechatService)
if (tmpSubscriptionAccount != tmpDeliveryAccount)
throw "Ignore"
var response
response = app.sendCustomerMsgByOpenid(woaId, openId, mediaId)
if (response == null || response.code == null)
throw "Internal Error: response or code is null."
if (response.code != 0)
throw response.message
msgs.appendChild(<message
id={msg.@id}
providerId={providerId}
status="1"
log="Sent"
/>)
}
catch (e)
{
log = e
if ( log == "Ignore" )
{
var excludeLog = "Ingored: not belong to the target wechat account " + BF_SERVICE_PREFIX + woaId
msgs.appendChild(<message id={msg.@id} status={0} log={excludeLog} noRetry="true"
providerId={providerId} />)
}
else
{
msgs.appendChild(<message id={msg.@id} status={2} log={log} noRetry="true"
providerId={providerId} failureReason="20" failureType="1" />)
}
}
}