Track the operation owning internal errors

This commit is contained in:
2026-11-05 13:42:56 +00:00
parent 106c808442
commit e881bbdcf4
8 changed files with 95 additions and 21 deletions

View File

@@ -39,7 +39,7 @@ func (r *Runner) resolveProfileSelection(
}
selectedProfile, err := r.profiles.GetProfile(ctx, lookupID)
if err != nil {
return nil, fmt.Errorf("%w: %w", ErrProfileLoad, err)
return nil, profileLookupError(err)
}
if selectedProfile == nil {
return nil, fmt.Errorf("%w: profile repository returned nil profile", ErrProfileLoad)
@@ -64,7 +64,7 @@ func (r *Runner) resolveProfileIdentity(ctx context.Context, profileID string) (
if indexed, ok := r.profiles.(profileIdentityRepository); ok {
identity, err := indexed.GetProfileIdentity(ctx, lookupID)
if err != nil {
return "", fmt.Errorf("%w: %w", ErrProfileLoad, err)
return "", profileLookupError(err)
}
return identity, nil
}
@@ -108,7 +108,7 @@ func (r *Runner) InspectProfile(
}
select {
case <-ctx.Done():
return nil, fmt.Errorf("%w: %w", ErrProfileLoad, ctx.Err())
return nil, &OperationError{Category: ErrProfileLoad, Cause: ctx.Err()}
default:
}
@@ -120,7 +120,7 @@ func (r *Runner) InspectProfile(
target.APIKey = ""
params, err := jsonvalue.CopyMap(target.ExtraParams)
if err != nil {
return nil, fmt.Errorf("%w: profile extra parameters: %w", ErrProfileLoad, err)
return nil, &OperationError{Category: ErrProfileLoad, Cause: fmt.Errorf("profile extra parameters: %w", err)}
}
target.ExtraParams = params