{"repo":"ztrue/tracerr","free":true,"listed":false,"github":"https://github.com/ztrue/tracerr","clone":"git clone https://github.com/ztrue/tracerr.git","description":"Golang errors with stack trace and source fragments.","language":"Go","stars":1120,"topics":["golang","go","stacktrace","debug","error-handling","errors","errors-log","source-map"],"license":"MIT","category":"dev-tools","readme_excerpt":"Golang Errors with Stack Trace and Source Fragments Tired of uninformative error output? Probably this will be more convenient: Example Find more executable examples in examples dir. How to Use Import Create New Error Or: Add Stack Trace to Existing Error If err is nil then it still be nil with no stack trace added. Print Error and Stack Trace Stack trace will be printed only if err is of type tracerr.Error , otherwise just error text will be shown. This will print error message and stack trace if any: This will add source code: It's able to set up number of lines of code to display for each frame, which is 6 by default: Or to set up number of lines before and after traced line: The same, but with color, which is much more useful: Save Output to Variable It's also able to save output to variable instead of printing it, which works the same way: Get Stack Trace Stack trace will be empty if err is not an instance of tracerr.Error . Or if err is of type tracerr.Error : Get Original Error Unwrapped error will be nil if err is nil and will be the same error if err is not an instance of tracerr.Error . Or if err is of type tracerr.Error : Performance Benchmarks for creating a new error with a stack trace of different depth:","default_branch":null,"files":null,"tree":[],"storefront":"/r/ztrue","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/ztrue/tracerr/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}