Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit bb164cc

Browse files
HomelessDinosaurjyecuschdavemooreuws
authored
fix: remove old error handling on resource creation (#661)
Co-authored-by: Jye Cusch <[email protected]> Co-authored-by: David Moore <[email protected]>
1 parent 45e943c commit bb164cc

File tree

5 files changed

+20
-63
lines changed

5 files changed

+20
-63
lines changed

docs/get-started/foundations/infrastructure/resources.mdx

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,17 @@ import (
9191
)
9292

9393
func main() {
94-
api, err := nitric.NewApi("public")
95-
if err != nil {
96-
fmt.Println(err)
97-
return
98-
}
94+
api := nitric.NewApi("public")
9995

10096
// ✅ This declaration will work
101-
bucket, err := nitric.NewBucket("files").Allow(nitric.BucketRead)
97+
bucket := nitric.NewBucket("files").Allow(nitric.BucketRead)
10298

10399
api.Get("/files/:name", func(ctx *apis.Ctx) {
104100
// ❌ This declaration won't work, since it's in a callback that's only called at runtime.
105-
badBucket, err := nitric.NewBucket("wont-work").Allow(nitric.BucketRead)
101+
badBucket := nitric.NewBucket("wont-work").Allow(nitric.BucketRead)
106102
})
107103

108-
if err := nitric.Run(); err != nil {
109-
fmt.Println(err)
110-
}
111-
112-
fmt.Println("Service has started")
104+
nitric.Run()
113105
}
114106
```
115107

@@ -202,14 +194,14 @@ import (
202194
)
203195

204196
func main() {
205-
api, err := nitric.NewApi("public")
197+
api := nitric.NewApi("public")
206198
if err != nil {
207199
fmt.Println(err)
208200
return
209201
}
210202

211203

212-
bucket, err := nitric.NewBucket("files").Allow(nitric.BucketRead)
204+
bucket := nitric.NewBucket("files").Allow(nitric.BucketRead)
213205

214206
// ❌ This access will not work
215207
fileContents, _ := bucket.Read(context.TODO(), "example.txt")
@@ -219,9 +211,7 @@ func main() {
219211
fileContents, _ := bucket.Read(context.TODO(), "example.txt")
220212
})
221213

222-
if err := nitric.Run(); err != nil {
223-
fmt.Println(err)
224-
}
214+
nitric.Run()
225215
}
226216
```
227217

@@ -389,10 +379,7 @@ var PublicApi nitric.Api
389379
var UpdateTopic nitric.SubscribableTopic
390380

391381
func init() {
392-
publicApi, err := nitric.NewApi("public")
393-
if err != nil {
394-
panic(err)
395-
}
382+
publicApi := nitric.NewApi("public")
396383

397384
PublicApi = publicApi
398385

@@ -424,9 +411,7 @@ func main() {
424411
})
425412
})
426413

427-
if err := nitric.Run(); err != nil {
428-
fmt.Println(err)
429-
}
414+
nitric.Run()
430415
}
431416
```
432417

@@ -445,11 +430,7 @@ func main() {
445430
println("got the message")
446431
})
447432

448-
if err := nitric.Run(); err != nil {
449-
fmt.Println(err)
450-
}
451-
452-
fmt.Println("Updates service has started")
433+
nitric.Run()
453434
}
454435
```
455436

@@ -644,9 +625,7 @@ func main() {
644625
// do something with the file
645626
})
646627

647-
if err := nitric.Run(); err != nil {
648-
fmt.Println(err)
649-
}
628+
nitric.Run()
650629
}
651630
```
652631

@@ -666,9 +645,7 @@ func main() {
666645
// do something with the file
667646
})
668647

669-
if err := nitric.Run(); err != nil {
670-
fmt.Println(err)
671-
}
648+
nitric.Run()
672649
}
673650
```
674651

docs/get-started/quickstart.mdx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,7 @@ import (
337337
)
338338

339339
func main() {
340-
api, err := nitric.NewApi("main")
341-
if err != nil {
342-
fmt.Println(err)
343-
return
344-
}
340+
api := nitric.NewApi("main")
345341

346342
api.Get("/hello/:name", func(ctx *apis.Ctx) {
347343
name := ctx.Request.PathParams()["name"]
@@ -353,9 +349,7 @@ func main() {
353349
ctx.Response.Body = []byte(fmt.Sprintf("Goodbye %s", name))
354350
})
355351

356-
if err := nitric.Run(); err != nil {
357-
fmt.Println(err)
358-
}
352+
nitric.Run()
359353
}
360354
```
361355

docs/index.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@ import (
153153
)
154154

155155
func main() {
156-
profiles, _ := nitric.NewBucket("profiles").Allow(nitric.BucketRead, nitric.BucketWrite, nitric.BucketDelete)
156+
profiles := nitric.NewBucket("profiles").Allow(nitric.BucketRead, nitric.BucketWrite, nitric.BucketDelete)
157157

158-
if err := nitric.Run(); err != nil {
159-
fmt.Println(err)
160-
}
158+
nitric.Run()
161159
}
162160
```
163161

docs/reference/go/api/api-delete.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ import (
2020
)
2121

2222
func main() {
23-
api, err := nitric.NewApi("public")
24-
if err != nil {
25-
return
26-
}
23+
api := nitric.NewApi("public")
2724

2825
api.Delete("/hello", func(ctx *apis.Ctx) {
2926
ctx.Response.Body = []byte("Hello World")

docs/reference/go/storage/bucket-downloadurl.mdx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ import (
5454
)
5555

5656
func main() {
57-
bucket, err := nitric.NewBucket("bucket-name").Allow(nitric.BucketRead)
58-
if err != nil {
59-
return
60-
}
57+
bucket := nitric.NewBucket("bucket-name").Allow(nitric.BucketRead)
6158

6259
downloadUrl, err := bucket.File("cat.png").DownloadUrl(context.TODO(), "cat.png", storage.WithPresignUrlExpiry(time.Minute*5))
6360
if err != nil {
@@ -80,15 +77,9 @@ import (
8077
)
8178

8279
func main() {
83-
api, err := nitric.NewApi("main")
84-
if err != nil {
85-
return
86-
}
80+
api := nitric.NewApi("main")
8781

88-
bucket, err := nitric.NewBucket("images").Allow(nitric.BucketRead)
89-
if err != nil {
90-
return
91-
}
82+
bucket := nitric.NewBucket("images").Allow(nitric.BucketRead)
9283

9384
api.Get("/images/:id", func(ctx *apis.Ctx) {
9485
id := ctx.Request.PathParams()["id"]

0 commit comments

Comments
 (0)