Use consistent error wrapping patterns to preserve error context and ensure proper error code propagation. Always: 1. Use vterrors.New/Errorf when creating new errors to include error codes
Use consistent error wrapping patterns to preserve error context and ensure proper error code propagation. Always:
Example:
// Don't do this:
if err != nil {
return fmt.Errorf("failed to delete workflow %s: %v", name, err)
}
// Do this instead:
if err != nil {
return vterrors.Wrapf(err, "failed to delete workflow %s", name)
}
// Don't do this:
if _, ok := err.(ConfigFileNotFoundError); ok {
return true
}
// Do this instead:
var configErr ConfigFileNotFoundError
if errors.As(err, &configErr) {
return true
}
// Don't do this:
return nil, fmt.Errorf("opcode: %v not supported", opcode)
// Do this instead:
return nil, vterrors.VT13001(fmt.Sprintf("opcode: %v not supported", opcode))
Enter the URL of a public GitHub repository