|
errors: Improve tests, unify interfaces, wrapping
The errors package is refactored so that for all
errors defined there are 3 functions with consistent
names:
* Is<type>(error) bool
Returns true if the error satifies <type> (i.e.
it was created with one of the two constructors
below for <type>.
* New<type>(error, string) error
Creates an error of <type> wrapping the given error
and adding the prefix to the message.
* <type>f(string, ...interface{}) error
Creates an error of <type> with a message, formatted
like fmt.Sprintf.
Dropped "Error" from type and function names (as they
already are in the "errors" package).
Moved utils.ErrorContextf in here, renaming it to
Maskf. A new helper called Contextf is added, which works
similarly to Maskf, but preserves the original error when
wrapping (if it's one of the known types), so that the
Is<type>() satifiers will work on the wrapped error as
well.
Added automatic exhaustive testing for each error
type in a way that makes it easier to add new types.
Few drive-by fixes made while fixing the rest of the
code base to use the new function names.
I realize we should use errgo for such things, but
we can easily change the errors package to use errgo
internally later.
https://code.launchpad.net/~dimitern/juju-core/396-improve-errors/+merge/215652
(do not edit description out of merge proposal)
Total comments: 6
Total comments: 12
Total comments: 4
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+689 lines, -551 lines) |
Patch |
 |
A |
[revision details]
|
View
|
1
2
3
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
 |
M |
cmd/juju/common.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
cmd/juju/debuglog.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
cmd/juju/debuglog_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
cmd/juju/deploy_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
cmd/juju/destroyenvironment_test.go
|
View
|
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
cmd/juju/destroymachine_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
cmd/jujud/machine.go
|
View
|
1
2
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
cmd/jujud/machine_test.go
|
View
|
1
2
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
container/lxc/instance.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/bootstrap/state.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/bootstrap/synctools.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/cloudinit.go
|
View
|
1
2
|
2 chunks |
+2 lines, -1 line |
0 comments
|
Download
|
 |
M |
environs/cloudinit/cloudinit.go
|
View
|
1
2
|
2 chunks |
+2 lines, -1 line |
0 comments
|
Download
|
 |
M |
environs/configstore/disk_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/filestorage/filestorage.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/filestorage/filestorage_test.go
|
View
|
|
1 chunk |
+4 lines, -4 lines |
0 comments
|
Download
|
 |
M |
environs/httpstorage/storage_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/imagemetadata/generate.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/jujutest/livetests.go
|
View
|
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
environs/jujutest/tests.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/open.go
|
View
|
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
environs/open_test.go
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
environs/simplestreams/simplestreams.go
|
View
|
|
6 chunks |
+6 lines, -6 lines |
0 comments
|
Download
|
 |
M |
environs/sshstorage/storage.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/sshstorage/storage_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/tools/simplestreams.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
environs/tools/tools.go
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
environs/tools/tools_test.go
|
View
|
|
5 chunks |
+5 lines, -5 lines |
0 comments
|
Download
|
 |
M |
errors/errors.go
|
View
|
1
2
|
1 chunk |
+182 lines, -130 lines |
0 comments
|
Download
|
 |
M |
errors/errors_test.go
|
View
|
1
2
3
|
2 chunks |
+174 lines, -87 lines |
0 comments
|
Download
|
 |
M |
juju/api.go
|
View
|
1
2
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
juju/conn.go
|
View
|
1
2
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
juju/conn_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
provider/azure/certfile.go
|
View
|
1
2
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
provider/azure/instancetype.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
provider/azure/storage_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
provider/common/destroy_test.go
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
provider/ec2/storage.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
provider/joyent/storage.go
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
provider/joyent/storage_test.go
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
provider/local/instance.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
provider/maas/environ_whitebox_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
provider/maas/storage.go
|
View
|
|
1 chunk |
+4 lines, -3 lines |
0 comments
|
Download
|
 |
M |
provider/maas/storage_test.go
|
View
|
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
provider/openstack/storage.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/addmachine.go
|
View
|
1
2
|
3 chunks |
+2 lines, -3 lines |
0 comments
|
Download
|
 |
M |
state/annotator.go
|
View
|
1
2
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
state/api/agent/machine_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/api/client.go
|
View
|
|
1 chunk |
+9 lines, -5 lines |
0 comments
|
Download
|
 |
M |
state/api/machiner/machiner_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/api/params/apierror.go
|
View
|
|
1 chunk |
+5 lines, -4 lines |
0 comments
|
Download
|
 |
M |
state/api/provisioner/provisioner_test.go
|
View
|
|
2 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
state/api/uniter/relation.go
|
View
|
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
state/api/uniter/unit_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/api/upgrader/unitupgrader_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/api/upgrader/upgrader_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/admin.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/charmrevisionupdater/updater_test.go
|
View
|
1
2
|
3 chunks |
+5 lines, -5 lines |
0 comments
|
Download
|
 |
M |
state/apiserver/client/api_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/client/client.go
|
View
|
1
2
|
4 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
 |
M |
state/apiserver/client/client_test.go
|
View
|
1
2
|
7 chunks |
+8 lines, -8 lines |
0 comments
|
Download
|
 |
M |
state/apiserver/client/destroy_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/client/status.go
|
View
|
1
2
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
state/apiserver/common/errors.go
|
View
|
|
1 chunk |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
state/apiserver/common/errors_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/deployer/deployer_test.go
|
View
|
1
2
|
4 chunks |
+4 lines, -3 lines |
0 comments
|
Download
|
 |
M |
state/apiserver/firewaller/firewaller_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/keymanager/keymanager.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/keyupdater/authorisedkeys.go
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
state/apiserver/machine/machiner.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/provisioner/provisioner_test.go
|
View
|
1
2
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
state/apiserver/uniter/uniter.go
|
View
|
|
4 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
 |
M |
state/apiserver/uniter/uniter_test.go
|
View
|
1
2
|
2 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
state/apiserver/upgrader/unitupgrader_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/upgrader/upgrader_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/usermanager/usermanager.go
|
View
|
1
2
|
1 chunk |
+2 lines, -1 line |
0 comments
|
Download
|
 |
M |
state/apiserver/usermanager/usermanager_test.go
|
View
|
1
2
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/charm_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/cleanup.go
|
View
|
|
6 chunks |
+6 lines, -6 lines |
0 comments
|
Download
|
 |
M |
state/cleanup_test.go
|
View
|
|
3 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
 |
M |
state/configvalidator_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/conn_test.go
|
View
|
|
1 chunk |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
state/environcapability_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/machine.go
|
View
|
1
2
|
17 chunks |
+20 lines, -21 lines |
0 comments
|
Download
|
 |
M |
state/machine_test.go
|
View
|
|
4 chunks |
+7 lines, -7 lines |
0 comments
|
Download
|
 |
M |
state/megawatcher.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/minimumunits.go
|
View
|
1
2
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
state/open.go
|
View
|
1
2
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/policy.go
|
View
|
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
state/prechecker_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/relation.go
|
View
|
1
2
|
4 chunks |
+4 lines, -5 lines |
0 comments
|
Download
|
 |
M |
state/relation_test.go
|
View
|
|
4 chunks |
+6 lines, -6 lines |
0 comments
|
Download
|
 |
M |
state/relationunit.go
|
View
|
1
2
|
3 chunks |
+2 lines, -3 lines |
0 comments
|
Download
|
 |
M |
state/relationunit_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/service.go
|
View
|
1
2
|
8 chunks |
+8 lines, -9 lines |
0 comments
|
Download
|
 |
M |
state/service_test.go
|
View
|
|
11 chunks |
+14 lines, -14 lines |
0 comments
|
Download
|
 |
M |
state/settings_test.go
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
state/state.go
|
View
|
1
2
|
8 chunks |
+9 lines, -11 lines |
0 comments
|
Download
|
 |
M |
state/state_test.go
|
View
|
1
2
|
17 chunks |
+19 lines, -19 lines |
0 comments
|
Download
|
 |
M |
state/tools_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
state/unit.go
|
View
|
1
2
|
13 chunks |
+15 lines, -13 lines |
0 comments
|
Download
|
 |
M |
state/unit_test.go
|
View
|
|
7 chunks |
+9 lines, -9 lines |
0 comments
|
Download
|
 |
M |
state/watcher.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
utils/trivial.go
|
View
|
|
2 chunks |
+0 lines, -11 lines |
0 comments
|
Download
|
 |
M |
worker/deployer/deployer_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
worker/instancepoller/machine_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
worker/instancepoller/updater.go
|
View
|
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
worker/peergrouper/worker.go
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
worker/provisioner/kvm-broker_test.go
|
View
|
1
2
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
worker/provisioner/lxc-broker_test.go
|
View
|
1
2
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
worker/provisioner/provisioner.go
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
 |
M |
worker/provisioner/provisioner_test.go
|
View
|
|
2 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
worker/uniter/charm/bundles.go
|
View
|
1
2
|
2 chunks |
+2 lines, -1 line |
0 comments
|
Download
|
 |
M |
worker/uniter/relation/relation.go
|
View
|
1
2
|
5 chunks |
+5 lines, -4 lines |
0 comments
|
Download
|
 |
M |
worker/uniter/relationer_test.go
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
worker/uniter/state.go
|
View
|
1
2
|
2 chunks |
+2 lines, -1 line |
0 comments
|
Download
|
 |
M |
worker/uniter/uniter_test.go
|
View
|
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
 |
M |
worker/upgrader/upgrader_test.go
|
View
|
|
3 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
Total messages: 9
|