question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Current games issue

See original GitHub issue
const nombre = args.slice([1]).join(' ');
const nombreUrl = nombre.replace(/\s/g, "%20").toLowerCase(); 
const summoner = await kayn.Summoner.by.name(nombre)
let game = await kayn.CurrentGame.by.summonerID(summoner.id) // awaiting doesn't solve it
console.log(typeof(game));

When trying to see the type of variable game if there is no current games for the Summoner, instead of the 404 object, the console returns an “Unhandled promise rejection” and I can’t reassign it nor see it’s type. Is this an issue or am I doing it wrong?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cnguycommented, Jun 18, 2019

Ohhh, I haven’t been reading carefully. you can try this:

const nombre = args.slice([1]).join(' ');
const nombreUrl = nombre.replace(/\s/g, "%20").toLowerCase();
let summoner = null;
try {
  summoner = await kayn.Summoner.by.name(nombre);
} catch (ex) {
  if (ex.statusCode == 404) game = null;
  else throw new Error("completely broken");
}
let game = null;
try {
  game = await kayn.CurrentGame.by.summonerID(summoner.id) // awaiting doesn't solve it
} catch (ex) {
  if (ex.statusCode == 404) game = null;
  else throw new Error("completely broken");
}
console.log(summoner, game)

Basically, if there’s a 404, just reassign null, otherwise if it’s some other error that mean something really bad happened (assuming retries are on), so just throw.

1reaction
cnguycommented, Jun 18, 2019

If you place it inside the try block, the whole try statement will run from start-to-finish unless an error occurs. So you’ll be able to catch 404’s, 500’s, etc of both Summoner and CurrentGame. Not sure about the scoping part, but IMO if the logic is “combined”, then put it all in one try block.

I would put it in there personally, unless you want specific error-handling on a case-by-case basis.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Popular Games Right Now - Gaming | Downdetector
Popular Games Right Now · Madden · Steam · Roblox · Origin · Call of Duty · Champions Legion · Playstation Network ·...
Read more >
Issues - Games World of Puzzles
In this October issue of GAMES WORLD OF PUZZLES, you'll find plenty of tricks and treats. Tricks, of course, because what fun is...
Read more >
Xbox Status - Xbox Support
Check the Xbox services, games, and apps for any service outages. ... Did this resolve your issue? Yes No. Problem with a game?...
Read more >
Epic Games Public Status
Welcome to Epic Games Public's home for real-time and historical data on system performance. ... Investigating - We are currently investigating this issue....
Read more >
7 Major Problems of Modern Video Games
7 Major Problems of Modern Video Games · 1. Plots That Have No Moral Base · 2. Glitches · 3. Baseless Segmentation of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found