Expose `Error` interface
Codonaut opened this issue · comments
The documentation for Execute
states:
// Internal library errors will match the interface Error and you can use type casting to check this.
But, the Error
type is unexported so I am unable to do a type check.
I believe this is the type you want: https://github.com/cep21/circuit/blob/master/v3/errors.go#L17
Yeah I saw that that is the type I want, but I suppose I was anticipating it to be exported in the forward.go file so I don't need to reference the versioned path. Using the versioned path works, but seems counter to the normal usage pattern where you don't need to peer into the v3 path.
If I've been using this wrong and in fact I should be referencing the v3 path then I can switch my imports across the board-- but in that case I would wonder why types are boosted to the top level in closers
and forward.go
.
forward.go exists because of backwards compatibility and go modules requiring a /v3 import path for SEMVER v3 libraries. If you're using go modules, then think of "github.com/cep21/circuit/Circuit" as v1 of the Circuit object.
The error interface is only supported in the v3 version of the library. I recommend using the /v3/ import path.
I would wonder why types are boosted to the top level in closers and forward.go
It was part of the modules migration to not break existing code. Because type Error
didn't exist during the modules migration, I didn't need to promote it. I would rather not promote it now since the correct way to use go modules is to put semver in the import path.
Ahhh ok, that makes perfect sense. I'll switch my code to use the v3 path then and add in a type assertion. Thanks for the help!