Skip to content

CLLocationError: name property ​

The name property is the category of the location error. Use it to determine what went wrong.

Value ​

A string, one of these six:

ValueMeaningProvided by
'NotAllowedError'No authorizationThe system, or the runtime determining it before calling the system. In both cases code is 1 and domain is 'kCLErrorDomain'
'LocationUnknownError'The location can't be determined at this moment. During continuous updates the system keeps tryingThe system (code is 0)
'NetworkError'A network problemThe system (code is 2)
'CLError'Other errors reported by the system; see codeThe system
'AbortError'requestLocation() was canceledThe runtime
'InvalidStateError'This can't be done right now: requesting a single location during continuous updates, requesting authorization while the app is in the background, or the usage description is missing from Info.plistThe runtime
  • code is 0 for both 'LocationUnknownError' and 'AbortError', so tell them apart by name, not just code.
  • Errors from the system whose error domain isn't kCLErrorDomain are also classified as 'CLError'.

Examples ​

js
const manager = new CLLocationManager();
manager.requestLocation().catch((err) => {
  if (err.name === 'NotAllowedError') {
    console.log('No permission');
  } else {
    console.log('Other error: ' + err.name);
  }
});

Effect: Without authorization, prints No permission.

Corresponding iOS API ​

No direct equivalent: in ObjC, look at NSError.code. kCLErrorDenied is 'NotAllowedError', kCLErrorLocationUnknown is 'LocationUnknownError', and kCLErrorNetwork is 'NetworkError'.

See also ​