ooni-probe-cli/internal/tracex
Simone Basso 83e3167ce2
refactor(tracex): internally represent errors as strings (#786)
There are two reasons why this is beneficial:

1. github.com/google/go-cmp is more annoying to use for comparing
data structures when there are interfaces to compare. Sure, there's
a recipe for teaching it to compare errors, but how about making
the errors trivially comparable instead?

2. if we want to send errors over the network, JSON serialization
works but we cannot unmarshal the resulting string back to an error,
so how about making this representation trivial to serialize (we
are not going this now, but we need this property for websteps and
it may be sensible to try to avoid to have duplicate code because
of that -- measurex currently duplicates many tracex functionality
and this is quite unfortunate because it slows development down)

Additionally, if an error is a string:

3. we can very easily use a switch for comparing its possible
values with "" representing the absence of errors, while it is
more complex to do the same when using a nullable string or even
an error (i.e., an interface)

4. if a type is not nullable, it's easier to write safe code for
it and we may want to refactor experiments to use the internal
representation of measurements for more robust processing code

For all these reasons, let's internally use strings in tracex.

The overall aim here is to reduce the duplicated code between pre
and post-measurex measurements (see https://github.com/ooni/probe/issues/2035).
2022-06-02 10:37:07 +02:00
..
archival_test.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
archival.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
dialer_test.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
dialer.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
doc.go refactor: move tracex outside of engine/netx (#782) 2022-06-02 00:50:55 +02:00
event.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
http_test.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
http.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
quic_test.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
quic.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
resolver_test.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
resolver.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
saver_test.go refactor: move tracex outside of engine/netx (#782) 2022-06-02 00:50:55 +02:00
saver.go refactor: move tracex outside of engine/netx (#782) 2022-06-02 00:50:55 +02:00
tls_test.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00
tls.go refactor(tracex): internally represent errors as strings (#786) 2022-06-02 10:37:07 +02:00