iris icon indicating copy to clipboard operation
iris copied to clipboard

Can we get the reporter?

Open corebreaker opened this issue 9 years ago • 6 comments

Hello,

Even if the reporter has exported methods, we can't get the reported configured neither in in Application nor in APIBuilder structure.

However, if we had an GetReporter method on them for getting the reporter, we could call Add or AddErr methods on a reporter.

corebreaker avatar Jul 18 '17 12:07 corebreaker

I can make a push request for that, it's easy.

corebreaker avatar Jul 18 '17 12:07 corebreaker

we can't get the reported configured neither in in Application nor in APIBuilder structure.

Yes we can, there is an exported function, app.GetReport() will return the errors as one, we don't give public access to/export the Reporter object itself because it's not used as one, it's combined with other error reporter inside the iris.Application#Build function, which is running on app.Run.

hiveminded avatar Jul 18 '17 16:07 hiveminded

So, how do you add an error from inside a Configurator to the caller of app.Run ? In normal case, an error done in initialization procedure should be transmitted to return of a calling of app.Run.

But in general case, if i wanted making a middleware, i'd like have add an error as like app.Favicon() do it.

With app.GetReporter().AddErr(an_error), or context.Application().GetReporter().AddErr(an_error), it would be possible.

corebreaker avatar Jul 18 '17 16:07 corebreaker

Okay, I see your point, I thought that letting iris describes its own errors and your application its own by using a custom errors.Reporter and wrap the app.Build was a better way of doing these things. It's a small PR function without conflicts but I think users will overuse that and report strange issues, so I think it's "dangerous" to export that function. But as you wish, we've to wait for @kataras to review that and share his opinion with us. I am OK with that if helps you.

hiveminded avatar Jul 18 '17 18:07 hiveminded

Ok, i understand.

corebreaker avatar Jul 18 '17 19:07 corebreaker

Hello @hiveminded , @corebreaker Let's accept that, will help to reduce end-developer's code for reporting errors.

kataras avatar Jul 18 '17 19:07 kataras