Giter Club home page Giter Club logo

Comments (3)

jwoertink avatar jwoertink commented on June 2, 2024

Just another thought on this, that {{ body }} line could just be moved to a different method like call_body or something. That actually might be the better solution.

private def call_body : Lucky::Response
  {{ body }}
end

def call
#...
%response = if %pipe_result.is_a?(Lucky::Response)
        %pipe_result
      else
        call_body
      end
#...
end

from lucky.

jwoertink avatar jwoertink commented on June 2, 2024

After a bunch of poking around... I can't get this to happen again. We tried using this in our app, and kept running in to issues. We ended up having to account for every single condition branch. I just tried to recreate this in Lucky, and I'm unable to.

I did check out my previous idea though, and I think this change may still be worth it...

Moving the {{ body }} to a separate method means that Crystal will catch your missing response with this:
image

This is in comparison to what Lucky does now which is:
image

Granted, the second one looks a lot nicer, and gives you some direction as to how to fix the error, but it doesn't tell you where the error is. For a new person, this error really isn't helpful because you may have just added 20 actions without checking and then ran this and have no clue where to fix the error.

For fun, I added #{@type} to my error to see if a simple fix to the pretty error could be done...
image

Notice it says Multiple::Index is the action where it failed.... but the action I actually messed up was Tests::MultiConditionWithEarlyReturn. I don't know why it thinks it's an action in a spec that I'm not even working near 🤷‍♂️

So I guess what I'm saying is, making this change is probably better anyway.

from lucky.

jwoertink avatar jwoertink commented on June 2, 2024

Alright, there you go
image

I feel like that's a bit of the best of both worlds scenario

from lucky.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.