Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ log.Println("AppHost directory:", dir)

`aspire.FormatError` turns an error into a message that is ready to log. When the AppHost server returns an error for a call, the error is an `*aspire.CapabilityError`, and `FormatError` adds its error code and the capability that failed. Use `errors.As` and the `Code`, `Message`, and `Capability` methods to read these values yourself. For any other error, `FormatError` returns `err.Error()`.

Collection handles, such as the one returned by `GetTags()`, keep their existing `ToJSON()` signature. Serialization failures are observable through the `Err()` method on the collection:

```go title="apphost.go"
payload := resource.GetTags().ToJSON()
if err := resource.GetTags().Err(); err != nil {
Comment on lines +73 to +74
log.Fatal(aspire.FormatError(err))
}
_ = payload
```

Callbacks can run concurrently with the main builder chain without racing the recorded error or lazily created collection accessors. An invalid request argument or a callback result that can't be encoded fails only that call and doesn't disconnect other pending operations.

## Cancellation

A method that accepts a cancellation token takes it in its options struct. For example, `aspire.RunOptions` has a `CancellationToken` field. Create a token with `aspire.NewCancellationToken`, pass it in the options, and call its `Cancel` method to cancel the call:
Expand Down
Loading