Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Commit 4043f3b

Browse files
authored
Merge pull request #32 from tablelandnetwork/bcalza/handleerr
handles err on writing an event
2 parents 3de5c82 + 71db0c1 commit 4043f3b

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

cmd/vaults/commands.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ func newListEventsCommand() *cli.Command {
565565

566566
if format == "table" {
567567
table := tablewriter.NewWriter(os.Stdout)
568-
table.SetHeader([]string{"CID", "Size", "Timestamp", "Archived", "Cache Expiry"})
568+
table.SetHeader([]string{"CID", "Timestamp", "Archived", "Cache Expiry"})
569569

570570
for _, event := range events {
571571
isArchived := "N"
@@ -577,7 +577,7 @@ func newListEventsCommand() *cli.Command {
577577
timestamp = time.Unix(event.Timestamp, 0).Format(time.RFC3339)
578578
}
579579
table.Append([]string{
580-
event.CID, fmt.Sprintf("%d", event.Size), timestamp, isArchived, event.CacheExpiry,
580+
event.CID, timestamp, isArchived, event.CacheExpiry,
581581
})
582582
}
583583
table.Render()

internal/app/models.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ type CacheDuration uint32
3535
type EventInfo struct {
3636
CID string `json:"cid"`
3737
Timestamp int64 `json:"timestamp"`
38-
Size uint32 `json:"size"`
3938
IsArchived bool `json:"is_archived"`
4039
CacheExpiry string `json:"cache_expiry"`
4140
}

pkg/vaultsprovider/provider.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,17 @@ func (bp *VaultsProvider) WriteVaultEvent(ctx context.Context, params app.WriteV
149149
_ = resp.Body.Close()
150150
}()
151151

152+
if resp.StatusCode != http.StatusOK {
153+
type response struct {
154+
Error string
155+
}
156+
var r response
157+
if err := json.NewDecoder(resp.Body).Decode(&r); err != nil {
158+
return fmt.Errorf("failed to decode response: %s", err)
159+
}
160+
161+
return fmt.Errorf(r.Error)
162+
}
163+
152164
return nil
153165
}

0 commit comments

Comments
 (0)