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)
|
private static Region? RegionFromFile(string filePath)
|
||||||
{
|
{
|
||||||
if (!File.Exists(filePath))
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException(filePath);
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
FileStream regionFile = new (filePath, FileMode.Open, FileAccess.Read, FileShare.Read, (int)new FileInfo(filePath).Length, FileOptions.SequentialScan);
|
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)!;
|
Region retRegion = JsonSerializer.Deserialize<Region>(regionFile, Region.serializerOptions)!;
|
||||||
@ -151,7 +154,7 @@ namespace Pathfinding
|
|||||||
case WayType.motorway:
|
case WayType.motorway:
|
||||||
case WayType.motorway_link:
|
case WayType.motorway_link:
|
||||||
case WayType.motorroad:
|
case WayType.motorroad:
|
||||||
return 17;
|
return 20;
|
||||||
case WayType.trunk:
|
case WayType.trunk:
|
||||||
case WayType.trunk_link:
|
case WayType.trunk_link:
|
||||||
case WayType.primary:
|
case WayType.primary:
|
||||||
@ -159,10 +162,9 @@ namespace Pathfinding
|
|||||||
return 10;
|
return 10;
|
||||||
case WayType.secondary:
|
case WayType.secondary:
|
||||||
case WayType.secondary_link:
|
case WayType.secondary_link:
|
||||||
return 7;
|
|
||||||
case WayType.tertiary:
|
case WayType.tertiary:
|
||||||
case WayType.tertiary_link:
|
case WayType.tertiary_link:
|
||||||
return 5;
|
return 6;
|
||||||
case WayType.unclassified:
|
case WayType.unclassified:
|
||||||
case WayType.residential:
|
case WayType.residential:
|
||||||
case WayType.road:
|
case WayType.road:
|
||||||
|
Reference in New Issue
Block a user