Comments (3)
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.
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.
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)
- Support for 'Person Tracking' HOT 1
- Desgin of the message queue HOT 6
- No license provided.
- After recent commit, does not compile HOT 1
- Raw POST body HOT 1
- Is there a way to ask Rollbar to print the errors in 'stderr' as well? HOT 5
- How to install? HOT 2
- Proxy HOT 3
- would be cool to have updated releases HOT 3
- Support local values and function args in stack traces HOT 1
- Use in middleware HOT 1
- Rollbar error: received response: 429 Too Many Requests HOT 1
- Use actual error class name for default error type HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rollbar.