Coder Social home page Coder Social logo

Comments (1)

puellanivis avatar puellanivis commented on August 19, 2024

Hm… https://github.com/pkg/errors/blob/master/stack.go#L113-L114

Yeah, it looks like we’re prefixing each frame output with a newline. This probably wasn’t noticed much, because the verbose formatting for errors themselves, was expecting this behavior and the output looked fine there, because it just doesn’t add a newline at the end of the error message, before dumping the stack frame.

More ideally, we probably only want newlines between frames, or after every frame. Both would then require the verbose formatting to inject a newline before getting to the frame output, but that’s pretty easy, and not really any sort of obstacle.

The arguments for “between each frame” vs “at the end of each frame” lies in how we consider the verbose output:

  • between each frame: we are still formatting an error message and programs should expect errors to not end in punctuation, let alone a newline. That way they can be easily composed into log messages, etc. And this option would at least not change the output of verbose formatted errors from what they were before.
  • at the end of each frame: But we are injecting newlines, so we’ve already broken proper expectations about what an error message should look like. (Yes, this has broken log ingest at my company before.) Since we are now effectively emitting a formatted text file, a proper text file should end in a newline.

from errors.

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.