3 ms·
It depends on how much context is needed. Imagine you have a Go library that parses JavaScript. Parsing can return an error, and it's very helpful to know infor
by maria2 4y ago
It depends on how much context is needed. Imagine you have a Go library that parses JavaScript. Parsing can return an error, and it's very helpful to know information like the line and column number. So you might have an error like this:
type ParseError struct {
Line int
Col int
Message string
}
The user of your library isn't expected to handle this error explicitly, but when they print the output, they can see exactly where the issue was.
- tsimionescu 4y agoDo you expect any piece of code to touch err.Line and err.Col? I definitely don't - I would expect the line and col to be included in the message of a basic string error.