Skip to content

Improve error handling#42

Open
matthiasdv wants to merge 1 commit intomainfrom
mdv/error-handling
Open

Improve error handling#42
matthiasdv wants to merge 1 commit intomainfrom
mdv/error-handling

Conversation

@matthiasdv
Copy link
Contributor

connect-node micro error responses look like this:

[#126] Received on "_INBOX.FvYLakh0ymAubAlyJ8p1cQ.p6AF4ctJ"
Nats-Service-Error: an error occurred: connector name can only contain letters, numbers, and underscores
Nats-Service-Error-Code: 500

connector name can only contain letters, numbers, and underscores

Where:

  • Nats-Service-Error is a friendly user-facing error description.
  • Nats-Service-Error-Code is an HTTP status that control-plane can use
  • body contains the full error, which is useful while developing against connect

Errors returned by the Connect SDK provide access to this:

// try to get a connector
conn, err := c.GetConnector(name, timeout)
if err != nil {

// use helper
friendlyMsg := client.ErrorMessage(err)

// or
var svcErr *client.ConnectServiceError
if errors.As(err, &svcErr) {
    // Full internal error (for logging)
    fullErr := svcErr.Error()

    // Friendly message for users "an error occurred: connector name can only contain letters, numbers, and underscores"
    friendly := svcErr.Body()

    // Error code "500"
    code := svcErr.Code
}

@matthiasdv matthiasdv marked this pull request as ready for review March 12, 2026 13:39
@matthiasdv matthiasdv requested a review from jordan-rash March 12, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant