You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2019/12/18 00:04:44 UTC
[mynewt-newt] 02/05: util: Add function: OneTimeWarningError(err
error)
This is an automated email from the ASF dual-hosted git repository.
ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit 9bb427ee378a300e26e912036fbeba8be6985768
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Thu Nov 7 10:11:17 2019 -0800
util: Add function: OneTimeWarningError(err error)
OneTimeWarningError displays the text of the specified error as a
warning if it has not been displayed yet. No-op if nil is passed in.
---
util/util.go | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/util/util.go b/util/util.go
index 900afbb..080a46e 100644
--- a/util/util.go
+++ b/util/util.go
@@ -854,6 +854,14 @@ func OneTimeWarning(text string, args ...interface{}) {
}
}
+// OneTimeWarningError displays the text of the specified error as a warning if
+// it has not been displayed yet. No-op if nil is passed in.
+func OneTimeWarningError(err error) {
+ if err != nil {
+ OneTimeWarning("%s", err.Error())
+ }
+}
+
func MarshalJSONStringer(sr fmt.Stringer) ([]byte, error) {
s := sr.String()
j, err := json.Marshal(s)