Jump to content
McKay Development

throw Error vs emit Error in steam-user


Camelia

Recommended Posts

Hello,

 

steam-user docs has Event error

 

Emitted when an error occurs during logon

 

 

At the same time, logon.js component is throwing errors during logOn calls

if(this.client.loggedOn) {
throw new Error("Already logged on, cannot log on again");
}

There are couple of places (2? 3?) where Error is thrown.

 

Why this discrepancy? It feels like some of the Error could be emitted, thus allowing client (as client == developer) handle them in the way they prefer. Right now I would have to wrap calls to logOn in try catch.

 

Do I miss use case here?

 

Thank you!

Link to comment
Share on other sites

I throw Errors in steam-user when you do something that you just shouldn't.

 

For example, there are no cases where you should be trying to log on when you're already logged on. An Error being thrown basically means that you failed a precondition.

 

For example, in the case quoted here, you need to check if you're already logged on before you attempt to log on again.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...