Skip to content

Commit 28018f4

Browse files
committed
shitload of links to docs
1 parent cc31822 commit 28018f4

File tree

7 files changed

+120
-118
lines changed

7 files changed

+120
-118
lines changed

assert/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ raise up quality of our software.
4747
The assert package offers a convenient way to set preconditions to code which
4848
allow us detect programming errors and API violations faster. Still allowing
4949
production-time error handling if needed. And everything is automatic. You can
50-
set asserter with SetDefault function or --asserter flag if Go's flag package is
50+
set asserter with [SetDefault] function or --asserter flag if Go's flag package is
5151
in use. This allows developer, operator and every-day user share the exact same
5252
binary but get the error messages and diagnostic they need.
5353
@@ -73,7 +73,7 @@ And assert package's configuration flags are inserted.
7373
assert.That's performance is equal to the if-statement thanks for inlining. And
7474
the most of the generics-based versions are about the equally fast. Practice has
7575
thought that we should prefer other than assert.That because by using detailed
76-
version like assert.Shorter we get precise error messages automatically. Some
76+
version like [assert.Shorter] we get precise error messages automatically. Some
7777
also prefer readability of specific asserters.
7878
7979
If your algorithm is performance-critical please run `make bench` in the err2

doc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ them. The CopyFile example shows how it works:
5050
5151
# Error checks and Automatic Error Propagation
5252
53-
The try package provides convenient helpers to check the errors. For example,
53+
The [github.com/lainio/err2/try] package provides convenient helpers to check the errors. For example,
5454
instead of
5555
5656
b, err := io.ReadAll(r)
@@ -94,7 +94,7 @@ tracer API:
9494
9595
# Flag Package Support
9696
97-
The err2 package supports Go's flags. All you need to do is to call flag.Parse.
97+
The err2 package supports Go's flags. All you need to do is to call [flag.Parse].
9898
And the following flags are supported (="default-value"):
9999
100100
-err2-log="nil"
@@ -105,7 +105,7 @@ And the following flags are supported (="default-value"):
105105
A name of the stream currently supported stderr, stdout or nil
106106
107107
Note, that you have called [SetErrorTracer] and others, before you call
108-
flag.Parse. This allows you set the defaults according your app's need and allow
108+
[flag.Parse]. This allows you set the defaults according your app's need and allow
109109
end-user change them during the runtime.
110110
111111
# Error handling

err2.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ type (
2020
// [ErrNotFound] ... [ErrNotEnabled] are similar no-error like [io.EOF] for
2121
// those who really want to use error return values to transport non errors.
2222
// It's far better to have discriminated unions as errors for function calls.
23-
// But if you insist the related helpers are in they [try] package:
24-
// try.IsNotFound, ...
23+
// But if you insist the related helpers are in they
24+
// [github.com/lainio/err2/try] package:
25+
// [github.com/lainio/err2/try.IsNotFound], ...
2526
//
2627
// [ErrRecoverable] and [ErrNotRecoverable] since Go 1.20 wraps multiple errors
2728
// same time, i.e. wrapped errors aren't list anymore but tree. This allows mark
@@ -60,9 +61,9 @@ var Stdnull = &nullDev{}
6061
//
6162
// Note. If you are still using sentinel errors you must be careful with the
6263
// automatic error annotation because it uses wrapping. If you must keep the
63-
// error value got from error checks: [try.To], you must disable automatic
64-
// error annotation (%w), or set the returned error values in the handler
65-
// function. Disabling can be done by setting second argument nil:
64+
// error value got from error checks: [github.com/lainio/err2/try.To], you must
65+
// disable automatic error annotation (%w), or set the returned error values in
66+
// the handler function. Disabling can be done by setting second argument nil:
6667
//
6768
// func SaveData(...) (err error) {
6869
// defer err2.Handle(&err, nil) // nil arg disable automatic annotation.
@@ -183,7 +184,7 @@ func Catch(a ...any) {
183184
}
184185

185186
// Throwf builds and throws (panics) an error. For creation it's similar to
186-
// fmt.Errorf. Because panic is used to transport the error instead of error
187+
// [fmt.Errorf]. Because panic is used to transport the error instead of error
187188
// return value, it's called only if you want to non-local control structure for
188189
// error handling, i.e. your current function doesn't have error return value.
189190
//

handlers.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
// Stderr is a built-in helper to use with [Handle] and [Catch]. It prints the
11-
// error to stderr and it resets the current error value. It's a handy Catch
11+
// error to stderr and it resets the current error value. It's a handy [Catch]
1212
// handler in main function.
1313
//
1414
// You can use it like this:
@@ -23,8 +23,8 @@ func Stderr(err error) error {
2323
return nil
2424
}
2525

26-
// Stdout is a built-in helper to use with Handle and Catch. It prints the
27-
// error to stdout and it resets the current error value. It's a handy Catch
26+
// Stdout is a built-in helper to use with [Handle] and [Catch]. It prints the
27+
// error to stdout and it resets the current error value. It's a handy [Catch]
2828
// handler in main function.
2929
//
3030
// You can use it like this:
@@ -39,13 +39,13 @@ func Stdout(err error) error {
3939
return nil
4040
}
4141

42-
// Noop is a built-in helper to use with Handle and Catch. It keeps the current
42+
// Noop is a built-in helper to use with [Handle] and [Catch]. It keeps the current
4343
// error value the same. You can use it like this:
4444
//
4545
// defer err2.Handle(&err, err2.Noop)
4646
func Noop(err error) error { return err }
4747

48-
// Reset is a built-in helper to use with Handle and Catch. It sets the current
48+
// Reset is a built-in helper to use with [Handle] and [Catch]. It sets the current
4949
// error value to nil. You can use it like this to reset the error:
5050
//
5151
// defer err2.Handle(&err, err2.Reset)
@@ -60,7 +60,7 @@ func Reset(error) error { return nil }
6060
// fmt.Println("ERROR:", err)
6161
// }))
6262
//
63-
// Note, that since Err helper we have other helpers like Stdout that allows
63+
// Note, that since Err helper we have other helpers like [Stdout] that allows
6464
// previous block be written as simple as:
6565
//
6666
// defer err2.Catch(err2.Stdout)

tracer.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,75 +6,75 @@ import (
66
"github.com/lainio/err2/internal/tracer"
77
)
88

9-
// ErrorTracer returns current io.Writer for automatic error stack tracing.
9+
// ErrorTracer returns current [io.Writer] for automatic error stack tracing.
1010
// The default value is nil.
1111
func ErrorTracer() io.Writer {
1212
return tracer.Error.Tracer()
1313
}
1414

15-
// PanicTracer returns current io.Writer for automatic panic stack tracing. Note
16-
// that runtime.Error types which are transported by panics are controlled by
17-
// this. The default value is os.Stderr.
15+
// PanicTracer returns current [io.Writer] for automatic panic stack tracing. Note
16+
// that [runtime.Error] types which are transported by panics are controlled by
17+
// this. The default value is [os.Stderr].
1818
func PanicTracer() io.Writer {
1919
return tracer.Panic.Tracer()
2020
}
2121

22-
// LogTracer returns a current io.Writer for the explicit try.Result.Logf
23-
// function and automatic logging used in err2.Handle and err2.Catch. The
22+
// LogTracer returns a current [io.Writer] for the explicit [try.Result.Logf]
23+
// function and automatic logging used in [Handle] and [Catch]. The
2424
// default value is nil.
2525
func LogTracer() io.Writer {
2626
return tracer.Log.Tracer()
2727
}
2828

29-
// SetErrorTracer sets a io.Writer for automatic error stack tracing. The err2
29+
// SetErrorTracer sets a [io.Writer] for automatic error stack tracing. The err2
3030
// default is nil. Note that the current function is capable to print error
3131
// stack trace when the function has at least one deferred error handler, e.g:
3232
//
3333
// func CopyFile(src, dst string) (err error) {
3434
// defer err2.Handle(&err) // <- error trace print decision is done here
3535
//
36-
// Remember that you can reset these with Flag package support. See
36+
// Remember that you can reset these with [flag] package support. See
3737
// documentation of err2 package's flag section.
3838
func SetErrorTracer(w io.Writer) {
3939
tracer.Error.SetTracer(w)
4040
}
4141

42-
// SetPanicTracer sets a io.Writer for automatic panic stack tracing. The err2
43-
// default is os.Stderr. Note that runtime.Error types which are transported by
42+
// SetPanicTracer sets a [io.Writer] for automatic panic stack tracing. The err2
43+
// default is [os.Stderr]. Note that [runtime.Error] types which are transported by
4444
// panics are controlled by this. Note also that the current function is capable
4545
// to print panic stack trace when the function has at least one deferred error
4646
// handler, e.g:
4747
//
4848
// func CopyFile(src, dst string) (err error) {
4949
// defer err2.Handle(&err) // <- panic trace print decision is done here
5050
//
51-
// Remember that you can reset these with Flag package support. See
51+
// Remember that you can reset these with [flag] package support. See
5252
// documentation of err2 package's flag section.
5353
func SetPanicTracer(w io.Writer) {
5454
tracer.Panic.SetTracer(w)
5555
}
5656

57-
// SetLogTracer sets a current io.Writer for the explicit try.Result.Logf
58-
// function and automatic logging used in err2.Handle and err2.Catch. The
57+
// SetLogTracer sets a current [io.Writer] for the explicit [try.Result.Logf]
58+
// function and automatic logging used in [Handle] and [Catch]. The
5959
// default is nil and then err2 uses std log package for logging.
6060
//
61-
// You can use the std log package to redirect other logging packages like glog
62-
// to automatically work with the err2 package. For the glog, add this line at
61+
// You can use the std log package to redirect other logging packages like [glog]
62+
// to automatically work with the err2 package. For the [glog], add this line at
6363
// the beginning of your app:
6464
//
6565
// glog.CopyStandardLogTo("INFO")
6666
//
67-
// Remember that you can reset these with Flag package support. See
67+
// Remember that you can reset these with [flag] package support. See
6868
// documentation of err2 package's flag section.
6969
func SetLogTracer(w io.Writer) {
7070
tracer.Log.SetTracer(w)
7171
}
7272

73-
// SetTracers a helper to set a io.Writer for error and panic stack tracing, the
74-
// log tracer is set as well. More information see SetErrorTracer,
75-
// SetPanicTracer, and SetLogTracer functions.
73+
// SetTracers a helper to set a [io.Writer] for error and panic stack tracing, the
74+
// log tracer is set as well. More information see [SetErrorTracer],
75+
// [SetPanicTracer], and [SetLogTracer] functions.
7676
//
77-
// Remember that you can reset these with Flag package support. See
77+
// Remember that you can reset these with [flag] package support. See
7878
// documentation of err2 package's flag section.
7979
func SetTracers(w io.Writer) {
8080
tracer.Error.SetTracer(w)

0 commit comments

Comments
 (0)