GithubHelp home page GithubHelp logo

Comments (3)

bpo avatar bpo commented on August 16, 2024 2

So then I suppose my question would be, how would one simplify the process of having to go through every single error check and adding the reporting code lines? Is it even possible? It's fine for 10 cases, but what if we had a big old app with hundreds of error checks?

This is a common area of confusion for people new to the language. One way to think of it is to realize that exceptions in other languages are just a secondary method of returning values (i.e. error values) from a function. A common pattern in Go is to have the second of two return values be an error type. If you have an error result, you can pass it back to the caller on and on until the point at which you want to act on it, using this package or whatever other logic your program demands.

This has become a longer discussion of application design, well beyond the scope of stvp/rollbar, so I'm going to close this one out. In addition to the article I linked to earlier there are lots of resources online about error handling in Go that would probably be better resources than my ad libbing in a github issue :)

from rollbar.

bpo avatar bpo commented on August 16, 2024

Let me know if I'm misreading, but I think you're referring to exception handling here. Go doesn't have such a concept. You can report errors anywhere in the stack by handling the error explicitly. You can pass errors up the stack (possibly to some more general error reporter) by explicit return value, not by catching and throwing. If you're new to error handling in Go, this article may be useful

from rollbar.

marcelgruber avatar marcelgruber commented on August 16, 2024

Hmmm, I suppose that I AM talking about exception handling then. I got confused because in a recent PHP project the framework I used had a function that was called whenever an exception was thrown and thus any exception that ever happened would automatically be reported because I was able to slap the reporting line in there. That's what was messing with me.

After reading a bit, you are in fact right that Go has no exceptions; at least in the conventional sense. https://golang.org/doc/faq#exceptions

So then I suppose my question would be, how would one simplify the process of having to go through every single error check and adding the reporting code lines? Is it even possible? It's fine for 10 cases, but what if we had a big old app with hundreds of error checks?

from rollbar.

Related Issues (14)

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.