Skip to content

Commit

Permalink
fix(locate me): added error handling in locate me
Browse files Browse the repository at this point in the history
  • Loading branch information
opensrc0 committed Apr 2, 2024
1 parent 800bcf4 commit 137a6c1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions __app/component/LocateMe/LocateMe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import Wrapper from '../Wrapper/Wrapper';
import { handleSuccess, handleError, handleLoading } from '../services/handlerService';
Expand Down Expand Up @@ -51,7 +51,7 @@ const getPincode = async (
return zipcode;
}
} catch (err) {
return handleError({ disbaleToast, msgType: 'ERROR', msg: failureMsg.invalidLatLng || 'Invalid Lat lng', failureCb });
return handleError({ disbaleToast, msgType: 'INVALID_LAT_LNG', msg: failureMsg.invalidLatLng || 'Invalid Lat lng', failureCb });
}

return '';
Expand Down Expand Up @@ -123,6 +123,18 @@ function LocateMe({
return true;
};

useEffect(() => {
globalThis.console.error = (...arg) => {
if (arg[0] && arg[0].indexOf('https://developers.google.com/maps/documentation/javascript/error-messages') !== -1) {
const errMsg = arg[0].split('\nhttps://developers.google.com/maps/documentation/javascript/error-messages')[0];

return handleError({ msgType: 'ERROR', msg: errMsg, failureCb });
}

return true;
};
}, []);

return (
React.Children.map(children || 'Use my current location', (child) => React.cloneElement(typeof child === 'string' ? <span>{child}</span> : child, {
onClick,
Expand Down

0 comments on commit 137a6c1

Please sign in to comment.