Skip to content

Commit ac8f630

Browse files
committed
comment: tell why DRY has to be there, no inlining
1 parent 9e3f44c commit ac8f630

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

try/try.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ func IsNotEnabled(err error) bool {
247247
// try.T(f.Close)("annotations")
248248
func T(err error) func(fs string, a ...any) {
249249
return func(fs string, a ...any) {
250+
// NOTE if block cannot be refactored 'because it wouldn't inline
251+
// then this whole function!
250252
if err != nil {
251253
er := fmt.Errorf(fs+handler.WrapError, append(a[1:], err)...)
252254
panic(er)
@@ -259,6 +261,8 @@ func T(err error) func(fs string, a ...any) {
259261
// f := try.T1(os.Open("filename")("cannot open cfg file")
260262
func T1[T any](v T, err error) func(fs string, a ...any) T {
261263
return func(fs string, a ...any) T {
264+
// NOTE if block cannot be refactored 'because it wouldn't inline
265+
// then this whole function!
262266
if err != nil {
263267
er := fmt.Errorf(fs+handler.WrapError, append(a[1:], err)...)
264268
panic(er)
@@ -270,6 +274,8 @@ func T1[T any](v T, err error) func(fs string, a ...any) T {
270274
// T2 is similar as [To2] but it let's you to annotate a possible error at place.
271275
func T2[T, U any](v T, u U, err error) func(fs string, a ...any) (T, U) {
272276
return func(fs string, a ...any) (T, U) {
277+
// NOTE if block cannot be refactored 'because it wouldn't inline
278+
// then this whole function!
273279
if err != nil {
274280
er := fmt.Errorf(fs+handler.WrapError, append(a[1:], err)...)
275281
panic(er)
@@ -281,6 +287,8 @@ func T2[T, U any](v T, u U, err error) func(fs string, a ...any) (T, U) {
281287
// T3 is similar as [To3] but it let's you to annotate a possible error at place.
282288
func T3[T, U, V any](v1 T, v2 U, v3 V, err error) func(fs string, a ...any) (T, U, V) {
283289
return func(fs string, a ...any) (T, U, V) {
290+
// NOTE if block cannot be refactored 'because it wouldn't inline
291+
// then this whole function!
284292
if err != nil {
285293
er := fmt.Errorf(fs+handler.WrapError, append(a[1:], err)...)
286294
panic(er)

0 commit comments

Comments
 (0)