-
-
Notifications
You must be signed in to change notification settings - Fork 34
fix an issue where some errors were ignored, and when the provided program did not perform any IO to show. #900
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
Conversation
Reviewer's GuideAdds handling for runtime program errors that were previously ignored and ensures a placeholder message is displayed when no output is produced by updating the execution flow and result embed formatting. Sequence diagram for improved error and output handling in code executionsequenceDiagram
participant User as actor User
participant Bot as Bot
participant RunCog as RunCog
participant CompilerService as CompilerService
User->>Bot: Submit code to run
Bot->>RunCog: _execute(compiler, code, options)
RunCog->>CompilerService: Execute code
CompilerService-->>RunCog: {compiler_error, program_error, program_output}
alt compiler_error exists and compiler != nim
RunCog->>RunCog: Append compiler_error to output_parts
end
alt program_error exists
RunCog->>RunCog: Append program_error to output_parts
end
alt program_output exists
RunCog->>RunCog: Append program_output to output_parts
end
RunCog->>RunCog: Join output_parts as output
RunCog->>RunCog: _create_result_embed(language, output, service)
RunCog-->>Bot: Embed with output or 'no result to show.'
Bot-->>User: Display result embed
Class diagram for updated RunCog error and output handlingclassDiagram
class RunCog {
...
async _execute(compiler, code, options) -> str | None
async _create_result_embed(language, output, service) -> Embed
}
RunCog : +_execute() now appends program_error if present
RunCog : +_create_result_embed() now shows 'no result to show.' if output is empty
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @HikariNee - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
tux/cogs/utility/run.py
Outdated
description = f"-# Service provided by {service_link}\n```{language}\n{output}\n```" | ||
|
||
description = ( | ||
f"-# Service provided by {service_link}\n```{language}\n{output if output else 'no result to show.'}\n```" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Replace if-expression with or
(or-if-exp-identity
)
f"-# Service provided by {service_link}\n```{language}\n{output if output else 'no result to show.'}\n```" | |
f"-# Service provided by {service_link}\n```{language}\n{output or 'no result to show.'}\n```" |
Explanation
Here we find ourselves setting a value if it evaluates toTrue
, and otherwiseusing a default.
The 'After' case is a bit easier to read and avoids the duplication of
input_currency
.
It works because the left-hand side is evaluated first. If it evaluates to
true then currency
will be set to this and the right-hand side will not be
evaluated. If it evaluates to false the right-hand side will be evaluated and
currency
will be set to DEFAULT_CURRENCY
.
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #900 +/- ##
========================================
+ Coverage 8.77% 8.87% +0.09%
========================================
Files 121 121
Lines 10187 10189 +2
Branches 1235 1236 +1
========================================
+ Hits 894 904 +10
+ Misses 9229 9219 -10
- Partials 64 66 +2
*This pull request uses carry forward flags. Click here to find out more.
☔ View full report in Codecov by Sentry. |
…ogram did not perform any IO to show.
Description
fix an issue where some errors were ignored, and when the provided program did not perform any IO to show.
Guidelines
My code follows the style guidelines of this project (formatted with Ruff)
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation if needed
My changes generate no new warnings
I have tested this change
Any dependent changes have been merged and published in downstream modules
I have added all appropriate labels to this PR
[Y] I have followed all of these guidelines.
How Has This Been Tested? (if applicable)
Tux dev server.
Please describe how you tested your code. e.g describe what commands you ran, what arguments, and any config stuff (if applicable)
NA
Screenshots (if applicable)
NA
Please add screenshots to help explain your changes.
Additional Information
NA
Summary by Sourcery
Include program errors in the output embed and display a default message when there's no program output.
Bug Fixes: