@@ -198,18 +198,24 @@ func (e *ExecutionContext) evaluate(
198
198
WithAwaitPromise (true ).
199
199
WithUserGesture (true )
200
200
if remoteObject , exceptionDetails , err = action .Do (cdp .WithExecutor (apiCtx , e .session )); err != nil {
201
- return nil , fmt .Errorf ("cannot evaluate expression (%s): %w" , expressionWithSourceURL , exceptionDetails )
201
+ return nil , fmt .Errorf ("cannot call function on expression (%q) " +
202
+ "in execution context (%d) in frame (%v): %w" ,
203
+ expressionWithSourceURL , e .id , e .Frame ().ID (), err )
202
204
}
203
205
if exceptionDetails != nil {
204
- return nil , fmt .Errorf ("cannot evaluate expression (%s): %w" , expressionWithSourceURL , exceptionDetails )
206
+ return nil , fmt .Errorf ("cannot call function on expression (%q) " +
207
+ "in execution context (%d) in frame (%v): %w" ,
208
+ expressionWithSourceURL , e .id , e .Frame ().ID (), err )
205
209
}
206
210
if remoteObject == nil {
207
211
return
208
212
}
209
213
if opts .returnByValue {
210
214
res , err = valueFromRemoteObject (apiCtx , remoteObject )
211
215
if err != nil {
212
- return nil , fmt .Errorf ("cannot extract value from remote object (%s): %w" , remoteObject .ObjectID , err )
216
+ return nil , fmt .Errorf ("cannot extract value from remote object (%s) " +
217
+ "using (%s) in execution context (%d) in frame (%v): %w" ,
218
+ remoteObject .ObjectID , expressionWithSourceURL , e .id , e .Frame ().ID (), err )
213
219
}
214
220
} else if remoteObject .ObjectID != "" {
215
221
// Note: we don't use the passed in apiCtx here as it could be tied to a timeout
@@ -220,7 +226,9 @@ func (e *ExecutionContext) evaluate(
220
226
for _ , arg := range args {
221
227
result , err := convertArgument (apiCtx , e , arg )
222
228
if err != nil {
223
- return nil , fmt .Errorf ("cannot convert argument (%q): %w" , arg , err )
229
+ return nil , fmt .Errorf ("cannot convert argument (%q) " +
230
+ "in execution context (%d) in frame (%v): %w" ,
231
+ arg , e .id , e .Frame ().ID (), err )
224
232
}
225
233
arguments = append (arguments , result )
226
234
}
@@ -237,18 +245,24 @@ func (e *ExecutionContext) evaluate(
237
245
WithAwaitPromise (true ).
238
246
WithUserGesture (true )
239
247
if remoteObject , exceptionDetails , err = action .Do (cdp .WithExecutor (apiCtx , e .session )); err != nil {
240
- return nil , fmt .Errorf ("cannot call function on expression (%q) in execution context (%d): %w" , expressionWithSourceURL , e .id , err )
248
+ return nil , fmt .Errorf ("cannot call function on expression (%q) " +
249
+ "in execution context (%d) in frame (%v): %w" ,
250
+ expressionWithSourceURL , e .id , e .Frame ().ID (), err )
241
251
}
242
252
if exceptionDetails != nil {
243
- return nil , fmt .Errorf ("cannot call function on expression (%q) in execution context (%d): %w" , expressionWithSourceURL , e .id , err )
253
+ return nil , fmt .Errorf ("cannot call function on expression (%q) " +
254
+ "in execution context (%d) in frame (%v): %w" ,
255
+ expressionWithSourceURL , e .id , e .Frame ().ID (), err )
244
256
}
245
257
if remoteObject == nil {
246
258
return
247
259
}
248
260
if opts .returnByValue {
249
261
res , err = valueFromRemoteObject (apiCtx , remoteObject )
250
262
if err != nil {
251
- return nil , fmt .Errorf ("cannot extract value from remote object (%s): %w" , remoteObject .ObjectID , err )
263
+ return nil , fmt .Errorf ("cannot extract value from remote object (%s) " +
264
+ "in execution context (%d) in frame (%v): %w" ,
265
+ remoteObject .ObjectID , e .id , e .Frame ().ID (), err )
252
266
}
253
267
} else if remoteObject .ObjectID != "" {
254
268
// Note: we don't use the passed in apiCtx here as it could be tied to a timeout
0 commit comments