@@ -132,7 +132,7 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
132132 opt (config )
133133 }
134134
135- if err := config . context .Err ( ); err != nil {
135+ if err := context .Cause ( config . context ); err != nil {
136136 return emptyT , err
137137 }
138138
@@ -161,9 +161,9 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
161161 case <- config .timer .After (delay (config , n , err )):
162162 case <- config .context .Done ():
163163 if config .wrapContextErrorWithLastError {
164- return emptyT , Error {config . context .Err ( ), lastErr }
164+ return emptyT , Error {context .Cause ( config . context ), lastErr }
165165 }
166- return emptyT , config . context .Err ( )
166+ return emptyT , context .Cause ( config . context )
167167 }
168168 }
169169 }
@@ -207,10 +207,10 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
207207 case <- config .timer .After (delay (config , n , err )):
208208 case <- config .context .Done ():
209209 if config .lastErrorOnly {
210- return emptyT , config . context .Err ( )
210+ return emptyT , context .Cause ( config . context )
211211 }
212212
213- return emptyT , append (errorLog , config . context .Err ( ))
213+ return emptyT , append (errorLog , context .Cause ( config . context ))
214214 }
215215
216216 shouldRetry = shouldRetry && n < config .attempts
0 commit comments