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.

ability to handle type errors and other checks with appropriate messages in commandsnext

See original GitHub issue

This is related to the commandsnext module.

I would like my bot to return an appropriate error message to the user when checks fail, such as wrong argument types, Cooldowns, etc.

For example:

public async Task Foo(CommandContext ctx, int bar) 

If a user says !foo someString, i’d like to be able to tell the user the usage of the !foo command. Right now if a check fails, then the bot fails silently and my users have no idea what’s going on.

The best workaround I can figure is to somehow catch it in the error delegate, and try and figure out what happened based on the generic exception, which is very much not ideal.

Perhaps checks could be paired with failure handlers that we can set.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

Emzi0767commented, Oct 8, 2020

We could then just call the base (your attribute check implementation) and send a message from there.

No. No. No. And, once again, no. Communication is not anywhere near the area of what a check should do. That’s what the event handlers should be doing.

A check should be doing a simple validation. Nothing more.

The problem outlined in here stems from complete lack of knowledge about how event-driven programming and polymorphism work, as well as not reading the docs.

Emzi0767commented, Oct 8, 2020

The exception gives you all the details, including the failed checks and the execution context. It’s all listed in the docs and provided examples.

Facts are not insults.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle errors with grace: failing silently is not an ...
Consolidate errors.​​ It's fine if you care about different kinds of errors which need to be handled differently, but do your users a...
Read more >
Should one check for every little error in C?
In general, code should deal with exceptional conditions wherever it is appropriate. Yes, this is a vague statement.
Read more >
c++ - Theory on error handling?
The types of errors in third party libraries are the same types of errors that occur in application code. Errors should be handled...
Read more >
2.5 Error Handling and Generation | Mastering Software ...
Proper error handling is an essential tool for any software developer so that you can design programs that are error tolerant. Creating clear...
Read more >
What is Exception Handling? - SearchSoftwareQuality
Exception handling is the process of responding to unwanted or unexpected events when a computer program runs. Exception handling deals with these events...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found