Improve some exception types.
This commit is contained in:
@@ -39,7 +39,7 @@ namespace OpenRA
|
|||||||
ChannelInfo info;
|
ChannelInfo info;
|
||||||
lock (Channels)
|
lock (Channels)
|
||||||
if (!Channels.TryGetValue(channelName, out info))
|
if (!Channels.TryGetValue(channelName, out info))
|
||||||
throw new Exception("Tried logging to non-existent channel " + channelName);
|
throw new ArgumentException("Tried logging to non-existent channel " + channelName, "channelName");
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
|||||||
fileOffset = head.FirstFileOffset;
|
fileOffset = head.FirstFileOffset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw new Exception("Cannot Resolve Remaining Stream");
|
throw new InvalidDataException("Cannot Resolve Remaining Stream");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -403,7 +403,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
|||||||
void ExtractFile(FileDescriptor file, Stream output, Action<int> onProgress = null)
|
void ExtractFile(FileDescriptor file, Stream output, Action<int> onProgress = null)
|
||||||
{
|
{
|
||||||
if (file.Flags.HasFlag(CABFlags.FileInvalid))
|
if (file.Flags.HasFlag(CABFlags.FileInvalid))
|
||||||
throw new Exception("File Invalid");
|
throw new InvalidDataException("File Invalid");
|
||||||
|
|
||||||
if (file.LinkFlags.HasFlag(LinkFlags.Prev))
|
if (file.LinkFlags.HasFlag(LinkFlags.Prev))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new Exception("Error occurred while parsing {0}".F(node.Key), e);
|
throw new InvalidDataException("Error occurred while parsing {0}".F(node.Key), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var kvp in nodes)
|
foreach (var kvp in nodes)
|
||||||
|
|||||||
@@ -756,7 +756,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
var uid = server.LobbyInfo.GlobalSettings.Map;
|
var uid = server.LobbyInfo.GlobalSettings.Map;
|
||||||
server.Map = server.ModData.MapCache[uid];
|
server.Map = server.ModData.MapCache[uid];
|
||||||
if (server.Map.Status != MapStatus.Available)
|
if (server.Map.Status != MapStatus.Available)
|
||||||
throw new Exception("Map {0} not found".F(uid));
|
throw new InvalidOperationException("Map {0} not found".F(uid));
|
||||||
|
|
||||||
server.LobbyInfo.Slots = server.Map.Players.Players
|
server.LobbyInfo.Slots = server.Map.Players.Players
|
||||||
.Select(p => MakeSlotFromPlayerReference(p.Value))
|
.Select(p => MakeSlotFromPlayerReference(p.Value))
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
protected UpgradeMultiplierTrait(UpgradeMultiplierTraitInfo info, string modifierType, string actorType)
|
protected UpgradeMultiplierTrait(UpgradeMultiplierTraitInfo info, string modifierType, string actorType)
|
||||||
{
|
{
|
||||||
if (info.Modifier.Length == 0)
|
if (info.Modifier.Length == 0)
|
||||||
throw new Exception("No modifiers in " + modifierType + " for " + actorType);
|
throw new ArgumentException("No modifiers in " + modifierType + " for " + actorType);
|
||||||
this.info = info;
|
this.info = info;
|
||||||
IsTraitDisabled = info.UpgradeTypes.Length > 0 && info.BaseLevel > 0;
|
IsTraitDisabled = info.UpgradeTypes.Length > 0 && info.BaseLevel > 0;
|
||||||
level = IsTraitDisabled ? 0 : info.BaseLevel;
|
level = IsTraitDisabled ? 0 : info.BaseLevel;
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ namespace OpenRA.Mods.D2k.UtilityCommands
|
|||||||
stream = File.OpenRead(filename);
|
stream = File.OpenRead(filename);
|
||||||
|
|
||||||
if (stream.Length == 0 || stream.Length % 4 != 0)
|
if (stream.Length == 0 || stream.Length % 4 != 0)
|
||||||
throw new Exception("The map is in an unrecognized format!");
|
throw new ArgumentException("The map is in an unrecognized format!", "filename");
|
||||||
|
|
||||||
Initialize(filename);
|
Initialize(filename);
|
||||||
FillMap();
|
FillMap();
|
||||||
|
|||||||
Reference in New Issue
Block a user