fixes #601: catch bad token during development
Showing
1 changed file
with
11 additions
and
2 deletions
@@ -162,9 +162,18 @@ | @@ -162,9 +162,18 @@ | ||
162 | options:NSAnchoredSearch & NSBackwardsSearch | 162 | options:NSAnchoredSearch & NSBackwardsSearch |
163 | range:NSMakeRange(0, [[referenceURL absoluteString] length])]]; | 163 | range:NSMakeRange(0, [[referenceURL absoluteString] length])]]; |
164 | } | 164 | } |
165 | - | ||
166 | - if ([[referenceURL pathExtension] isEqualToString:@"json"] && (dataObject = [NSString brandedStringWithContentsOfURL:referenceURL encoding:NSUTF8StringEncoding error:nil]) && dataObject) | 165 | + |
166 | + NSError *error = nil; | ||
167 | + | ||
168 | + if ([[referenceURL pathExtension] isEqualToString:@"json"] && (dataObject = [NSString brandedStringWithContentsOfURL:referenceURL encoding:NSUTF8StringEncoding error:&error]) && dataObject) | ||
167 | { | 169 | { |
170 | + if (error && [error.domain isEqual:NSURLErrorDomain] && error.code == -1012) | ||
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 |
-
Please register or login to post a comment