Code Monkey home page Code Monkey logo

Comments (9)

simonmichael avatar simonmichael commented on May 6, 2024 1

Nice! $25 donated to EFF.

from cmdargs.

simonmichael avatar simonmichael commented on May 6, 2024

Or, indeed, avoid calling error at all.

from cmdargs.

ndmitchell avatar ndmitchell commented on May 6, 2024

Probably a custom exception type, and then a throw would be my guess, which would then default to not having the stack trace. Good spot.

from cmdargs.

simonmichael avatar simonmichael commented on May 6, 2024

/me adds a bounty to this issue: codemill$25

from cmdargs.

ndmitchell avatar ndmitchell commented on May 6, 2024

Please note that I am unable to accept bounties (the amount of paperwork from my day job would be too much hassle), so if it does get fixed to your satisfaction and you want to, please donate any money to a charity of your choice.

That said, a bounty does make it clear that it's an important issue, so it's helpful to see.

from cmdargs.

simonmichael avatar simonmichael commented on May 6, 2024

Thanks Neil. I'll reply here:

The problem is you are calling processValue, which is essentially process but with an error on the Left. > See https://hackage.haskell.org/package/cmdargs-0.10.16/docs/src/System-Console-CmdArgs-Explicit.html#processValue

I suspect you might get better results if you were to handle the error yourself doing:

case process m args of
Left x -> do hPutStrLn stderr x; exitFailure
Right x -> return x
Should I add a processValueIO that does that? My guess is that processValue will never present exactly > the UI you want.

I now understand differences betwee process/processArgs/processValue better. You're right, it's an easy fix on my side: change processValue mode args to either errorWithoutStackTrace id $ process mode args. So that's good. But also, I think processValue should be calling errorWithoutStackTrace. I believe processArgs already does, which I realised after some head-scratching.

Re bounty - not even a simple personal donation ? Ok, will do! I too like the signalling effect of bounties.

from cmdargs.

ndmitchell avatar ndmitchell commented on May 6, 2024

processArgs does the hPutStrLn/exitFailure combo, since it's in the IO monad. Unfortunately processValue isn't so it can't do that. Note that hPutStrLn gives you more control than error since it removes the *** Exception prefix as well.

from cmdargs.

simonmichael avatar simonmichael commented on May 6, 2024

Ok, but is it ever the right behaviour for cmdargs to show a stack trace to command line users ?

from cmdargs.

ndmitchell avatar ndmitchell commented on May 6, 2024

No, it's not, I decided you are right. I've made 2 changes in the newly released 0.10.17:

Add processValueIO for more controlled error messages
#529, don't include the stack trace in processValue

from cmdargs.

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.