MCPcopy Index your code
hub / github.com/docker/docker-agent / AddError

Method AddError

pkg/session/store.go:1220–1235  ·  view source on GitHub ↗

AddError appends a recorded error item to a session at the next position. The error payload is stored as JSON in the message_json column, reusing the existing schema (item_type discriminates the row).

(ctx context.Context, sessionID string, e *Error)

Source from the content-addressed store, hash-verified

1218// The error payload is stored as JSON in the message_json column, reusing the
1219// existing schema (item_type discriminates the row).
1220func (s *SQLiteSessionStore) AddError(ctx context.Context, sessionID string, e *Error) error {
1221 if sessionID == "" {
1222 return ErrEmptyID
1223 }
1224
1225 errJSON, err := json.Marshal(e)
1226 if err != nil {
1227 return fmt.Errorf("marshaling error: %w", err)
1228 }
1229
1230 _, err = s.db.ExecContext(ctx,
1231 `INSERT INTO session_items (session_id, position, item_type, message_json)
1232 VALUES (?, (SELECT COALESCE(MAX(position), -1) + 1 FROM session_items WHERE session_id = ?), 'error', ?)`,
1233 sessionID, sessionID, string(errJSON))
1234 return err
1235}
1236
1237// UpdateSessionTokens updates only token/cost fields.
1238func (s *SQLiteSessionStore) UpdateSessionTokens(ctx context.Context, sessionID string, inputTokens, outputTokens int64, cost float64) error {

Callers 1

Calls 1

ExecContextMethod · 0.80

Tested by 1