From c5069819b8fc21eec4834850471b9e842bbdade4 Mon Sep 17 00:00:00 2001 From: Mal Wood-Santoro Date: Wed, 27 Oct 2021 12:48:40 -0700 Subject: [PATCH 1/5] catch No Route response --- src/actions/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/actions/index.js b/src/actions/index.js index d599549..6507b0f 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -79,6 +79,10 @@ function fetchDirections() { return dispatch(setError(data.error)); } + if (data.message === "No route found") { + return dispatch(setError("No route found")); + } + dispatch(setError(null)); if (!data.routes[routeIndex]) dispatch(setRouteIndex(0)); dispatch(setDirections(data.routes)); @@ -93,6 +97,7 @@ function fetchDirections() { }; request.onerror = () => { + console.log('on error') dispatch(setDirections([])); return dispatch(setError(JSON.parse(request.responseText).message)); }; From e44fd483b323e7f3ce6262a2345d98f11bf1a283 Mon Sep 17 00:00:00 2001 From: Mal Wood-Santoro Date: Wed, 27 Oct 2021 12:49:57 -0700 Subject: [PATCH 2/5] remove console.log --- src/actions/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/actions/index.js b/src/actions/index.js index 6507b0f..ff845f5 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -97,7 +97,6 @@ function fetchDirections() { }; request.onerror = () => { - console.log('on error') dispatch(setDirections([])); return dispatch(setError(JSON.parse(request.responseText).message)); }; From 2bf4a9efdf7e8b7aa5fe9e548c8b7e5c935e0cae Mon Sep 17 00:00:00 2001 From: Mal Wood-Santoro Date: Wed, 3 Nov 2021 11:19:47 -0700 Subject: [PATCH 3/5] add inline comment --- src/actions/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/actions/index.js b/src/actions/index.js index ff845f5..4ad2bae 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -78,7 +78,8 @@ function fetchDirections() { dispatch(setDirections([])); return dispatch(setError(data.error)); } - + + // Catch no route responses if (data.message === "No route found") { return dispatch(setError("No route found")); } From 69f03217ad0f9393508f6b55bd61e4b4c5a24c9c Mon Sep 17 00:00:00 2001 From: Mal Wood-Santoro Date: Wed, 12 Jan 2022 11:54:26 -0800 Subject: [PATCH 4/5] update comment --- src/actions/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/index.js b/src/actions/index.js index 4ad2bae..5c6cfa3 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -79,7 +79,7 @@ function fetchDirections() { return dispatch(setError(data.error)); } - // Catch no route responses + // Catch no route responses and display message to user if (data.message === "No route found") { return dispatch(setError("No route found")); } From ae666f0cb512c0fcb3146a9709aa852b9c23207e Mon Sep 17 00:00:00 2001 From: Mal Wood-Santoro Date: Wed, 12 Jan 2022 11:59:10 -0800 Subject: [PATCH 5/5] fix linting issues --- src/actions/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index 5c6cfa3..655c0c6 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -80,8 +80,8 @@ function fetchDirections() { } // Catch no route responses and display message to user - if (data.message === "No route found") { - return dispatch(setError("No route found")); + if (data.message === 'No route found') { + return dispatch(setError('No route found')); } dispatch(setError(null));