diff --git a/source/cartastraccia/actor.d b/source/cartastraccia/actor.d index a08f218..8e3d8a2 100644 --- a/source/cartastraccia/actor.d +++ b/source/cartastraccia/actor.d @@ -126,48 +126,48 @@ * "public/channels/.html"; * Function executed in a task. */ -void feedActor(immutable string feedName, immutable string path, immutable uint retries) @trusted +void feedActor(immutable string feedName, immutable string path, immutable uint retries) @trusted nothrow { RSS rss; - URL url = URL(path); try { + URL url = URL(path); auto req = Request(); req.keepAlive = false; req.timeout = ACTOR_REQ_TIMEOUT; auto res = req.get(path); string tmp = res.responseBody.data.assumeUTF; validate(tmp); - if(tmp.empty) { - throw new Exception("Empty response from " ~ feedName ~ - ", removing from feeds."); - } + if(tmp.empty) { + throw new Exception("Empty response from " ~ feedName ~ + ", removing from feeds."); + } parseRSS(rss, tmp); + rss.match!( + (ref InvalidRSS i) { + logWarn("Invalid feed at: "~path); + logWarn("Caused by: \""~i.element~"\": "~i.content); + }, + (ref FailedRSS f) { + logWarn("Failed to load feed: "~ feedName); + logWarn("Error: "~f.msg); + }, + (ref ValidRSS vr) { + immutable fileName = "public/channels/"~feedName~".html"; + createHTMLPage(vr, feedName, fileName); + }); + + listenOnce(feedName, rss); + } catch (Exception e) { if(retries < ACTOR_MAX_RETRIES) { feedActor(feedName, path, retries+1); // retry by recurring return; } - rss = FailedRSS(e.msg); } - rss.match!( - (ref InvalidRSS i) { - logWarn("Invalid feed at: "~path); - logWarn("Caused by: \""~i.element~"\": "~i.content); - }, - (ref FailedRSS f) { - logWarn("Failed to load feed: "~ feedName); - logWarn("Error: "~f.msg); - }, - (ref ValidRSS vr) { - immutable fileName = "public/channels/"~feedName~".html"; - createHTMLPage(vr, feedName, fileName); - }); - - listenOnce(feedName, rss); } /** @@ -220,7 +220,7 @@ /** * Listen for messages from the webserver */ -void listenOnce(immutable string feedName, ref RSS rss) { +void listenOnce(immutable string feedName, ref RSS rss) { bool quit = false;