WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a098977

Browse files
committed
Fix example
1 parent 4f30b8a commit a098977

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

examples/simple/main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ func main() {
2323
}
2424

2525
logger := logrus.New()
26-
c := dnapi.NewClient("api-example/1.0", *server)
26+
c, err := dnapi.NewClient("api-example/1.0", *server)
27+
if err != nil {
28+
logger.WithError(err).Fatal("Failed to create API client")
29+
}
2730

2831
// initial enrollment example
2932
config, pkey, creds, meta, err := c.Enroll(context.Background(), logger, *code)
3033
if err != nil {
31-
logger.WithError(err).Error("Failed to enroll")
34+
logger.WithError(err).Fatal("Failed to enroll")
3235
}
3336

3437
config, err = dnapi.InsertConfigPrivateKey(config, pkey)
3538
if err != nil {
36-
logger.WithError(err).Error("Failed to insert private key into config")
39+
logger.WithError(err).Fatal("Failed to insert private key into config")
3740
}
3841

3942
fmt.Printf(
@@ -70,6 +73,7 @@ func main() {
7073
config, err = dnapi.InsertConfigPrivateKey(config, pkey)
7174
if err != nil {
7275
logger.WithError(err).Error("Failed to insert private key into config")
76+
continue
7377
}
7478

7579
creds = newCreds

0 commit comments

Comments
 (0)