-
Notifications
You must be signed in to change notification settings - Fork 611
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor
internal/pkg/install
package
Improve closing logic and add additional log statements. Signed-off-by: Dmitriy Matrenichev <[email protected]>
- Loading branch information
Showing
4 changed files
with
128 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
package install | ||
|
||
func WrapOnErr(fn func() error, msg string) func() error { | ||
return wrapOnErr(fn, msg) | ||
} | ||
|
||
func LogError(clientClose func() error) { | ||
logError(clientClose) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
package install_test | ||
|
||
import ( | ||
"errors" | ||
"log" | ||
"os" | ||
|
||
"github.com/siderolabs/talos/internal/pkg/install" | ||
) | ||
|
||
func ExampleWrapOnErr() { | ||
log.SetFlags(log.Lshortfile) | ||
log.SetOutput(os.Stdout) | ||
|
||
fn := install.WrapOnErr(alwaysErr, "context for the error") | ||
|
||
defer install.LogError(fn) | ||
|
||
install.LogError(fn) | ||
|
||
// Output: | ||
// export_test.go:12: context for the error: always an error | ||
} | ||
|
||
func alwaysErr() error { | ||
return errors.New("always an error") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters