News for hackers. Stuff that matters.
Re:Error stack traces in Go with x/xerror by konart on Tuesday August 24, 2021 @03:08AM (#28285907)
>Exceptions are for the former, which Go still supports via Panic().

The panics are there to be used only in cases where the further code execution is impossible. Not to inform the developer about an error.

Errors are a general solution to report an unexpected event during execution. The destination of such report depends on the part of code the program failed.

Re:Error stack traces in Go with x/xerror by laumars on Tuesday August 24, 2021 @03:57AM (#28286125)
I get that what you’ve posted is the official description but it doesn’t really explain the distinction well IMO. Eg there are plenty of environmental reasons you’d need to cease execution but giving the user a stack trace isn’t helpful. So be describing the two as who the target recipient of the error is helps. Or at least I think it does.

Personally my one gripe with Gos errors is that EOF is handled as an error.

Re:Error stack traces in Go with x/xerror by konart on Wednesday August 25, 2021 @10:01AM (#28301816)
> Eg there are plenty of environmental reasons you’d need to cease execution but giving the user a stack trace isn’t helpful.

Not sure I got this part. If you want to stop the program and don't to print the usual panic messages into the console - you can log\print whatever you want and call os.Exit().

At the same time you can log stack trace without panicing.

>Or at least I think it does.

Maybe, it's just that "the code has failed and the developer needs to be informed what to fix" applies to errors just a much as to panics. The only difference is that an error is the situation during the execution where you can continue the job and a panic requires execution to stop (in most cases).

At the same time panic are 'developers only'.

Re:Error stack traces in Go with x/xerror by laumars on Thursday August 26, 2021 @01:41PM (#28318022)
You’re arguing the same points I’m making :)