Authored by Justin R. Miller

fixes #601: catch bad token during development

@@ -163,8 +163,17 @@ @@ -163,8 +163,17 @@
163 range:NSMakeRange(0, [[referenceURL absoluteString] length])]]; 163 range:NSMakeRange(0, [[referenceURL absoluteString] length])]];
164 } 164 }
165 165
166 - if ([[referenceURL pathExtension] isEqualToString:@"json"] && (dataObject = [NSString brandedStringWithContentsOfURL:referenceURL encoding:NSUTF8StringEncoding error:nil]) && dataObject) 166 + NSError *error = nil;
  167 +
  168 + if ([[referenceURL pathExtension] isEqualToString:@"json"] && (dataObject = [NSString brandedStringWithContentsOfURL:referenceURL encoding:NSUTF8StringEncoding error:&error]) && dataObject)
  169 + {
  170 + if (error && [error.domain isEqual:NSURLErrorDomain] && error.code == -1012)
167 { 171 {
  172 +#ifdef DEBUG
  173 + NSAssert(![[dataObject lowercaseString] hasSuffix:@"invalid token\"}"], @"invalid token in use");
  174 +#endif
  175 + }
  176 +
168 return [self initWithTileJSON:dataObject enablingDataOnMapView:mapView]; 177 return [self initWithTileJSON:dataObject enablingDataOnMapView:mapView];
169 } 178 }
170 179