Throw exception instead of returning null when file not found.
This commit is contained in:
parent
aa05aad5b3
commit
c705fdb63a
@ -44,8 +44,11 @@ namespace Pathfinding
|
||||
|
||||
private static Region? RegionFromFile(string filePath)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
throw new FileNotFoundException(filePath);
|
||||
return null;
|
||||
}
|
||||
|
||||
FileStream regionFile = new (filePath, FileMode.Open, FileAccess.Read, FileShare.Read, (int)new FileInfo(filePath).Length, FileOptions.SequentialScan);
|
||||
Region retRegion = JsonSerializer.Deserialize<Region>(regionFile, Region.serializerOptions)!;
|
||||
@ -151,7 +154,7 @@ namespace Pathfinding
|
||||
case WayType.motorway:
|
||||
case WayType.motorway_link:
|
||||
case WayType.motorroad:
|
||||
return 17;
|
||||
return 20;
|
||||
case WayType.trunk:
|
||||
case WayType.trunk_link:
|
||||
case WayType.primary:
|
||||
@ -159,10 +162,9 @@ namespace Pathfinding
|
||||
return 10;
|
||||
case WayType.secondary:
|
||||
case WayType.secondary_link:
|
||||
return 7;
|
||||
case WayType.tertiary:
|
||||
case WayType.tertiary_link:
|
||||
return 5;
|
||||
return 6;
|
||||
case WayType.unclassified:
|
||||
case WayType.residential:
|
||||
case WayType.road:
|
||||
|
Loading…
Reference in New Issue
Block a user