@@ -257,22 +257,21 @@ public async Task<dynamic> GoToAsync(string url, Dictionary<string, string> opti
257257 DefaultNavigationTimeout ;
258258
259259 var watcher = new NavigationWatcher ( _frameManager , mainFrame , timeout , options ) ;
260-
261260 var navigateTask = Navigate ( _client , url , referrer ) ;
262261
263262 await Task . WhenAll (
264263 navigateTask ,
265264 watcher . NavigationTask
266265 ) ;
267266
268- var error = ! string . IsNullOrEmpty ( navigateTask . Result ) ? navigateTask . Result : watcher . NavigationTask . Result ;
267+ var exception = navigateTask . Exception ?? watcher . NavigationTask . Exception ;
269268
270269 watcher . Cancel ( ) ;
271270 _networkManager . RequestCreated -= createRequestEventListener ;
272271
273- if ( ! string . IsNullOrEmpty ( error ) )
272+ if ( exception != null )
274273 {
275- throw new NavigationException ( error ) ;
274+ throw new NavigationException ( exception . Message , exception ) ;
276275 }
277276
278277 Request request = null ;
@@ -377,21 +376,18 @@ private Task Reload()
377376 }
378377
379378
380- private async Task < string > Navigate ( Session client , string url , string referrer )
379+ private async Task Navigate ( Session client , string url , string referrer )
381380 {
382- try
381+
382+ dynamic response = await client . SendAsync ( "Page.navigate" , new
383383 {
384- dynamic response = await client . SendAsync ( "Page.navigate" , new Dictionary < string , object >
385- {
386- { "url" , url } ,
387- { "referrer" , referrer }
388- } ) ;
384+ url ,
385+ referrer = referrer ?? string . Empty
386+ } ) ;
389387
390- return response . ErrorText ;
391- }
392- catch ( Exception ex )
388+ if ( response . errorText != null )
393389 {
394- return ex . Message ;
390+ throw new NavigationException ( response . errorText ) ;
395391 }
396392 }
397393
0 commit comments