luckyframework / luckyframework/avram

Better error for new operation run

Open
#557 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

improve error experience
Dominant language
Crystal
Stars
183
Forks
67
PR merge metrics
No merged PRs in 30d

Description

When switching to the new operations, you may forget to remove the yield, and this causes a confusing error saying you need to define run. But you may look at it and say "I did..".

To get around this, we could make run not abstract and instead just make it raise a compile time error with our own error message. Doing this would allow us to control the error to suggest "try removing yield".

abstract class Operation

  def run
    {% raise <<-ERROR
           Operations must define `run` with no blocks or arguments.

           Try this...

               > remove yield from your run method
         ERROR
     %}
  end
end

The error message could use a little work, but that's the idea.

Maybe related: https://github.com/crystal-lang/crystal/issues/9771

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Operation abstraction and the new operations implementation, then review the related Crystal issue #9771 for compile-time error behavior. Done means an operation that still defines run with yield receives a clear compile-time message suggesting that yield be removed, while valid operations continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.