Skip to content

Commit

Permalink
Handle node error message in handlebar template too
Browse files Browse the repository at this point in the history
  • Loading branch information
lwindolf committed Jan 16, 2025
1 parent 009c289 commit 7e47337
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 61 deletions.
2 changes: 2 additions & 0 deletions js/helpers/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ if (Handlebars) {
'===': v1 === v2 ? true : false,
'!=': v1 != v2 ? true : false,
'!==': v1 !== v2 ? true : false,
'gt': v1 > v2 ? true : false,
'>': v1 > v2 ? true : false,
'>=': v1 >= v2 ? true : false,
'lt': v1 < v2 ? true : false,
'<': v1 < v2 ? true : false,
'<=': v1 <= v2 ? true : false,
'||': v1 || v2 ? true : false,
Expand Down
60 changes: 1 addition & 59 deletions js/htmlview.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,65 +72,7 @@ async function load_node(data, baseURL, direction) {
author : metadata_get(node, "author"),
copyright : metadata_get(node, "copyright"),
description : metadata_get(node, "description"),
homepage : metadata_get(node, "homepage"),
errorDetails : (() => {
if (!node.error)
return null;

return `<span>There was a problem when fetching this subscription!</span>
<ul>
<li>
${parseStatus(1, node.error)} <span>1. Authentication</span>
</li>
<li>
${parseStatus(2, node.error)} <span>2. Download</span>
</li>
<li>
${parseStatus(4, node.error)} <span>3. Feed Discovery</span>
</li>
<li>
${parseStatus(8, node.error)} <span>4. Parsing</span>
</li>
</ul>
<span class="details">
<b><span>Details:</span></b>
${(1 == node.error)?`
<p><span>Authentication failed. Please check the credentials and try again!</span></p>
`:''}
${(2 == node.error)?`
${node.httpError?`
<p>
${node.httpErrorCode >= 100?`HTTP ${node.httpErrorCode}: `:''}<br/>
${node.httpError}
</p>
`:''}
${node.updateError?`
<p>
<span>There was an error when downloading the feed source:</span>
<pre class="errorOutput">${node.updateError}</pre>
</p>
`:''}
${node.filterError?`
<p>
<span>There was an error when running the feed filter command:</span>
<pre class="errorOutput">${node.filterError}</pre>
</p>
`:''}
`:''}
${(4 == node.error)?`
<p><span>The source does not point directly to a feed or a webpage with a link to a feed!</span></p>
`:''}
${(8 == node.error)?`
<p><span>Sorry, the feed could not be parsed!</span></p>
<pre class="errorOutput">${node.parseError}</pre>
<p><span>You may want to contact the author/webmaster of the feed about this!</span></p>
`:''}
</span>`;
})()
homepage : metadata_get(node, "homepage")
});

contentCleanup ();
Expand Down
64 changes: 62 additions & 2 deletions js/node.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,67 @@

{{#if node.error}}
<div id="errors">
{{{ errorDetails }}}
<_span>There was a problem when fetching this subscription!</_span>
<ul>
<li>
{{#compare node.error '==' 1}}⛔{{/compare}}
{{#compare node.error 'gt' 1}}✅{{/compare}}
<_span>1. Authentication</_span>
</li>
<li>
{{#compare node.error '==' 2}}⛔{{/compare}}
{{#compare node.error 'gt' 2}}✅{{/compare}}
{{#compare node.error 'lt' 2}}⬜{{/compare}}
<_span>2. Download</_span>
</li>
<li>
{{#compare node.error '==' 4}}⛔{{/compare}}
{{#compare node.error 'gt' 4}}✅{{/compare}}
{{#compare node.error 'lt' 4}}⬜{{/compare}}
<_span>3. Feed Discovery</_span>
</li>
<li>
{{#compare node.error '==' 8}}⛔{{/compare}}
{{#compare node.error 'lt' 8}}⬜{{/compare}}
<_span>4. Parsing</_span>
</li>
</ul>

<span class="details">
<b><_span>Details:</_span></b>

{{#compare node.error '==' 1}}
<p><_span>Authentication failed. Please check the credentials and try again!</_span></p>
{{/compare}}
{{#compare node.error '==' 2}}
{{#if node.httpError}}
<p>
{{#compare node.httpErrorCode "gt" 99}}HTTP {{node.httpErrorCode}}{{/compare}}
{{node.httpError}}
</p>
{{/if}}
{{#if node.updateError}}
<p>
<_span>There was an error when downloading the feed source:</_span>
<pre class="errorOutput">{{node.updateError}}</pre>
</p>
{{/if}}
{{#if node.filterError}}
<p>
<_span>There was an error when running the feed filter command:</_span>
<pre class="errorOutput">{{node.filterError}}</pre>
</p>
{{/if}}
{{/compare}}
{{#compare node.error '==' 4}}
<p><_span>The source does not point directly to a feed or a webpage with a link to a feed!</_span></p>
{{/compare}}
{{#compare node.error '==' 8}}
<p><_span>Sorry, the feed could not be parsed!</_span></p>
<pre class="errorOutput">{{node.parseError}}</pre>
<p><_span>You may want to contact the author/webmaster of the feed about this!</_span></p>
{{/compare}}
</span>
</div>
{{/if}}

Expand All @@ -43,7 +103,7 @@
</head>
<body>
</body>
<script>
<script type="module">
import { load_node } from '/js/htmlview.js';

REPLACE_MARKER
Expand Down

0 comments on commit 7e47337

Please sign in to comment.