Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Fixing wasm error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Feb 7, 2024
1 parent 819e23f commit 7e853d4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions wasm/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package main

import (
"context"
"encoding/json"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -49,8 +50,12 @@ func postMessage(result *internal.BulkResponse) {
if len(result.Payload) > 0 {
response.Set("payload", string(result.Payload))
}
if result.Error != "" {
response.Set("error", result.Error)
if result.Error != nil {
ed, err := json.Marshal(result.Error)
if err != nil {
response.Set("error", fmt.Sprintf("failed to marshal error: %s", err.Error()))
}
response.Set("error", string(ed))
}
if result.IsFinal {
response.Set("is_final", true)
Expand Down

0 comments on commit 7e853d4

Please sign in to comment.