Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception in example: hn.nim (Hacker News) #113

Closed
Bahm opened this issue Nov 26, 2020 · 3 comments
Closed

Unhandled exception in example: hn.nim (Hacker News) #113

Bahm opened this issue Nov 26, 2020 · 3 comments

Comments

@Bahm
Copy link

Bahm commented Nov 26, 2020

hn.nim throws a KeyError exception when comments are disabled.

It works if you replace:

characters $call.json["descendants"].getInt() & " comments"

With:

try:
  characters $call.json["descendants"].getInt() & " comments"
except KeyError:
  characters "comments disabled"

The HN website just says "3 hours ago | hide" so it isn't a perfect match.

Here's the JSON for a HN post with comments disabled:

{
  "by": "thomaspaulmann",
  "id": 25217586,
  "score": 1,
  "time": 1606374063,
  "title": "Raycast (YC W20) Is Hiring Fullstack Software Engineers (EU, Remote)",
  "type": "job",
  "url": "https://raycast.com/jobs/software-engineer-fullstack"
}
@alt-tosc
Copy link
Contributor

Similar issue, solved with a similar fix:

try:
  let uri = parseUri(call.json["url"].getStr())
  characters "(" & uri.hostname & ")"
except KeyError:
  characters ""

@treeform
Copy link
Owner

treeform commented Dec 1, 2020

Thanks, ill fix it!

@treeform
Copy link
Owner

treeform commented Dec 5, 2020

Fixed: e67ff45

@treeform treeform closed this as completed Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants