Use PositionError with Geolocation

Here is my code.

.subscribe((data) => {
if(data.coords !== undefined) {
console.log(‘Your location is ON’)
else {
console.log(‘Please turn ON your device location’);

Using chrome browser I can check whether Location is on or off using this code. But using android device I can’t do that.

I want to use PositionError within this code. But I don’t know where to use it. Please help me.

Ok. I found a solution. Here it is,