From 2cb3800105d65db42054a5734efa769351453f24 Mon Sep 17 00:00:00 2001 From: anekos Date: Wed, 4 Aug 2010 10:42:15 +0000 Subject: エラー時に停止するように。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38165 d0d07461-0603-4401-acd4-de1884942a52 --- twittperator.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'twittperator.js') diff --git a/twittperator.js b/twittperator.js index c63a69d..3f333ee 100755 --- a/twittperator.js +++ b/twittperator.js @@ -1136,21 +1136,25 @@ let buf = ""; let interval = setInterval(function () { - let len = sis.available(); - if (len <= 0) - return; - let data = sis.read(len); - let lines = data.split(/\n/); - if (lines.length > 2) { - lines[0] = buf + lines[0]; - for (let [, line] in Iterator(lines.slice(0, -1))) { - try { - onMsg(JSON.parse(line), line); - } catch (e) {} + try { + let len = sis.available(); + if (len <= 0) + return; + let data = sis.read(len); + let lines = data.split(/\n/); + if (lines.length > 2) { + lines[0] = buf + lines[0]; + for (let [, line] in Iterator(lines.slice(0, -1))) { + try { + onMsg(JSON.parse(line), line); + } catch (e) {} + } + buf = lines.slice(-1)[0]; + } else { + buf += data; } - buf = lines.slice(-1)[0]; - } else { - buf += data; + } catch (e) { + stop(); } }, 500); -- cgit v1.2.3