捕获 yammer 嵌入错误

capture yammer embed error

我已将 yammer 源添加到我的站点

try{      
yam.connect.embedFeed(
          { container: '#embedded-feed',
            network: 'fourleaf.com',
            feedType: 'group',                // can be 'group', 'topic', or 'user'          
            feedId: '123'                     // feed ID from the instructions above
            ,config: {
                 defaultGroupId: 3257958      // specify default group id to post to 
            }
      });  
}
catch(exception ex){
//error handling code here
}  

如果用户没有接受使用政策,yammer 会抛出一个错误,指出 x-frame 选项未启用。

我试图在 catch 块中捕获这个错误,但它没有被捕获! 我可以在控制台中看到错误,但未调用 catch 块中的代码

或者在 yammer feed 嵌入选项中是否有可用的成功功能

您是否尝试过使用错误事件侦听器?

yam.on('error', handleError);

然后可以在 handleError 函数中执行 catch 块中的代码。

https://developer.yammer.com/docs/feed-events

yammer 嵌入现在有事件处理程序。在你的 catch 块或你想要的任何地方试试这个,

 yam.on('error', function(){
        console.error('an error occured');
 });