Handle decompression errors
This commit is contained in:
parent
4b356118a6
commit
6bcbe0ea9f
3 changed files with 12 additions and 3 deletions
|
@ -64,6 +64,9 @@ proc fetch*(url: Uri; oldApi=false): Future[JsonNode] {.async.} =
|
||||||
echo "fetch error: ", result.getError
|
echo "fetch error: ", result.getError
|
||||||
release(token, true)
|
release(token, true)
|
||||||
raise rateLimitError()
|
raise rateLimitError()
|
||||||
|
except ZippyError as e:
|
||||||
|
echo "decompression error: ", e.msg, ", url: ", url
|
||||||
|
raise newException(InternalError, "decompression failed: " & $url)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
echo "error: ", e.msg, ", token: ", token[], ", url: ", url
|
echo "error: ", e.msg, ", token: ", token[], ", url: ", url
|
||||||
if "length" notin e.msg and "descriptor" notin e.msg:
|
if "length" notin e.msg and "descriptor" notin e.msg:
|
||||||
|
|
|
@ -13,6 +13,7 @@ import routes/[
|
||||||
unsupported, embed, resolver, router_utils]
|
unsupported, embed, resolver, router_utils]
|
||||||
|
|
||||||
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
|
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
|
||||||
|
const issuesUrl = "https://github.com/zedeus/nitter/issues"
|
||||||
|
|
||||||
let configPath = getEnv("NITTER_CONF_FILE", "./nitter.conf")
|
let configPath = getEnv("NITTER_CONF_FILE", "./nitter.conf")
|
||||||
let (cfg, fullCfg) = getConfig(configPath)
|
let (cfg, fullCfg) = getConfig(configPath)
|
||||||
|
@ -75,11 +76,15 @@ routes:
|
||||||
error Http404:
|
error Http404:
|
||||||
resp Http404, showError("Page not found", cfg)
|
resp Http404, showError("Page not found", cfg)
|
||||||
|
|
||||||
|
error InternalError:
|
||||||
|
echo error.exc.msg
|
||||||
|
const link = a("open a GitHub issue", href = issuesUrl)
|
||||||
|
resp Http500, showError(&"An error occurred, please {link} with the URL you tried to visit.", cfg)
|
||||||
|
|
||||||
error RateLimitError:
|
error RateLimitError:
|
||||||
echo error.exc.msg
|
echo error.exc.msg
|
||||||
resp Http429, showError("Instance has been rate limited.<br>Use " &
|
const link = a("another instance", href = instancesUrl)
|
||||||
a("another instance", href = instancesUrl) &
|
resp Http429, showError(&"Instance has been rate limited.<br>Use {link} or try again later.", cfg)
|
||||||
" or try again later.", cfg)
|
|
||||||
|
|
||||||
extend unsupported, ""
|
extend unsupported, ""
|
||||||
extend preferences, ""
|
extend preferences, ""
|
||||||
|
|
|
@ -6,6 +6,7 @@ genPrefsType()
|
||||||
|
|
||||||
type
|
type
|
||||||
RateLimitError* = object of CatchableError
|
RateLimitError* = object of CatchableError
|
||||||
|
InternalError* = object of CatchableError
|
||||||
|
|
||||||
Token* = ref object
|
Token* = ref object
|
||||||
tok*: string
|
tok*: string
|
||||||
|
|
Loading…
Reference in a new issue