90 Commits

Author SHA1 Message Date
c19df894fd Added DoIfNot to the v2 API.
This call allows wrapping an error if it is not already of the target
type.
2024-08-23 18:57:08 -06:00
c5460cacf3 Unit tests now utilize the correct v2 package. 2024-01-16 13:53:43 -07:00
8b91430bd0 Updated README to point to new repository sources. 2024-01-16 13:52:33 -07:00
601424bdd3 Bumped branch for v2 and requiring Go v1.20+. 2024-01-16 13:50:08 -07:00
ca27529cfb Branching v1 in preparation for v2 API. 2024-01-16 13:49:21 -07:00
a37e74b7d9 Added As(). v1.3.1 2021-10-17 22:32:31 -06:00
af0a7639c6 Minor grammatical and preferential changes to ease reading. v1.3.0 2021-10-08 22:05:07 -06:00
922798dd2f Bump minimum Go version to v1.13. 2021-10-08 22:02:14 -06:00
941b01a7fe Added IfNotError. 2021-10-08 21:58:37 -06:00
864ab96c69 Updated CHANGELOG for pending version. 2021-10-08 21:22:34 -06:00
2cbbd7044e Document (minor) changes to the API. 2021-10-08 21:22:06 -06:00
d255ab0263 Typo. 2021-10-08 21:21:58 -06:00
bb1029be13 Minor but noteworthy API changes. In particular:
.Do() and .Wrap() are no longer aliases. .Do() returns a mostly-pristine
copy of the error with the passed in value set to its upstream error
chain. .Wrap() now includes and retains other values such as the
error's associated code and metadata. As a consequence, .Wrap() obviates
some use cases such as remembering whether to call .Do() first when
using .Add() (which often leads to unexpected results if the opposite is
ever done instead).

GuaranteeError now calls .Copy().Wrap() instead of .Do().

New() and Errorf() are no longer aliases to their respective functions
in the errors and fmt packages; instead, they return an Error as an
error interface.
2021-10-08 21:17:35 -06:00
a1e436c2dc Updated changelog. v1.2.0 2021-05-07 01:17:07 -06:00
8c5ef7e9d9 Fixed Unwrap behavior to be analogous to the stdlib. 2021-05-07 01:12:41 -06:00
43342711e2 Added unit test for Unwrap. 2021-05-07 01:12:18 -06:00
41d999bde5 Additions to support API updates. 2021-05-07 01:01:01 -06:00
3f3615fed9 Several changes to defined API (and fixes):
1) Public API now actually publishes DeepEqual. This was omitted for a
   long enough period so as to be embarrassing.

2) Wrap() is now part of the public API and will be deprecating the more
   confusingly-named Do().

3) Actually test UnfurlOn to see if it works as the documentation
   claimed. It didn't, so we fixed it.
2021-05-07 00:59:34 -06:00
6f4e2428c8 Remove extraneous t.Error. 2021-05-07 00:58:58 -06:00
5cfd45f437 Expanding unit tests. 2021-05-06 23:56:09 -06:00
e4e759c187 Updated changelog to include new updates scheduled for v1.2.0. 2021-05-06 16:01:37 -06:00
cbdc3b5a04 Documented formatted errors. 2021-05-06 15:56:23 -06:00
1d8544cfae Added error formatting API. 2021-05-06 15:46:14 -06:00
a87804e821 Documentation update. 2021-05-06 15:29:59 -06:00
7f1eed9111 Updated notes on SetCode. v1.1.0 2021-05-01 21:38:29 -06:00
19c8d7b226 Changed behavior/name of clone/copy *slightly*. Clone()'ing will never
flag the generated error as a copy.
2021-05-01 21:36:37 -06:00
483145e0fa Typographical errors. 2021-05-01 21:28:31 -06:00
315b46f0ab Further edits, clarifications, and fixes. 2021-05-01 21:26:45 -06:00
a8b50d6157 Simplify GuaranteeError. Additional wrapping effort unnecessary. 2021-05-01 21:03:17 -06:00
4d75362be2 Update README to reflect API changes. 2021-05-01 20:46:06 -06:00
88896cbdc2 Deprecate OriginalError, replacing it with Initiator. 2021-05-01 20:45:52 -06:00
553c89074a Deprecate OriginalError. 2021-05-01 20:45:31 -06:00
44dea49262 Added SetCode behavior change to changelog. 2021-05-01 19:27:49 -06:00
da6fbe0ea9 SetCode now operates on a copy of the error rather than modifying the
top level type.

Previously, the intent was for SetCode to be used in circumstances where
an error was replicated with .Do. However, there may be cases where this
isn't possible. This ensures that only copies are modified.
2021-05-01 19:26:35 -06:00
9f3f12c9a1 Added changelog. 2021-05-01 16:54:39 -06:00
9291b3693e IsNil now correctly tests for nil values. 2021-05-01 16:35:21 -06:00
c1335990be Updated comments and minor internal API changes.
1) Comments have been clarified where they weren't entirely clear.

2) Guarantee will now return &nilError{} when passed a nil value.

3) Other Guarantee* functions are now documented as per their intended
purpose.

4) A new IsNil function has been added to determine if the Error under
scrutiny is, in fact, a nilError, nil, or otherwise.

5) Error.Equal and Error.Is now call the top level functions internally
to minimize code footprint.
2021-05-01 16:33:17 -06:00
cd72579062 Added a nilError type for callers invoking Guarantee(nil).
This circumvents some potentially problematic situations where an error
is returned that appears to be valid despite containing nothing.
2021-05-01 16:27:28 -06:00
506acf8060 Unit tests updated to reflect codebase changes for:
1) Add behavior changes.

2) Attaching values.

3) Get* types.
2021-05-01 16:02:48 -06:00
5558b685d5 Added Get* functions to exposed interface. Missing from prior commit. 2021-05-01 16:00:09 -06:00
a3f0cd6a25 Added Makefile for convenience. Mostly for running tests. 2021-05-01 15:56:20 -06:00
082a088e90 API changes, as minimal as possible, in accordance with reasonable
sensibilities:

1) Errors track their clone state to determine if they're a top-level
error.

2) Top-level Clone(Error) function now calls .Clone() on the argument
it's passed rather than vice-versa.

3) Added Copy() function which acts in accordance with the intended
purpose that Clone() sufficed. Clone() has been retained for API
compatibility.

4) Calling Add() on a top-level error, directly, will create a copy and
return the copy with the specified metadata values attached. Add() will
never change the metadata associated with a top-level error type. Use
Attach() instead.

5) Attach() has been added as a separate method for working with
metadata values on top-level error types.

6) GetString, GetInt, GetFloat, and GetError have been added for
extricating typed metadata values for convenience.
2021-05-01 15:52:39 -06:00
6000f38f6a Added top-level Unwrap, UnfurlOn, and Contains.
Unwrap acts analogously to the standard library errors.Unwrap.

UnfurlOn acts similarly to Unfurl with the exception that it accepts a
function against which every error in the chain will be applied.

Contains returns true if the parent error type contains the specified
error.
2021-04-30 23:51:48 -06:00
8a2002a540 Ooops: defaults were not actually committed. 2021-04-30 23:34:17 -06:00
82805b4b43 Added Unwrap method for stdlib compatibility. 2021-04-30 23:33:53 -06:00
0f592fe385 ErrorTracer was renamed to Error. Reflect this in the README. 2021-04-30 23:33:38 -06:00
5e9bdefa28 Added container for default error types offered alongside the errors
package.
2021-04-30 23:32:42 -06:00
a84fe5936b Add compatibility type alias. 2021-04-30 23:24:07 -06:00
200d7feecb Unexport concrete type and rename ErrorTracer interface to Error. 2021-04-30 23:23:19 -06:00
b170a33e79 Bump copyright. v1.0.0 2021-02-14 15:30:52 -07:00