mirror of https://github.com/ppy/osu
Use a custom channel not found exception.
This commit is contained in:
parent
5e95995429
commit
263e68de91
|
@ -84,7 +84,7 @@ public void AddLink(string text, string url, LinkAction linkType = LinkAction.Ex
|
|||
{
|
||||
channelManager.OpenChannel(linkArgument);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
catch (ChannelNotFoundException)
|
||||
{
|
||||
//channel was not found
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public void OpenChannel(string name)
|
|||
throw new ArgumentNullException(nameof(name));
|
||||
|
||||
CurrentChannel.Value = AvailableChannels.FirstOrDefault(c => c.Name == name)
|
||||
?? throw new ArgumentException($"Channel {name} was not found.");
|
||||
?? throw new ChannelNotFoundException(name);
|
||||
}
|
||||
|
||||
public void OpenUserChannel(User user)
|
||||
|
@ -298,4 +298,14 @@ private void load(IAPIProvider api)
|
|||
api.Register(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ChannelNotFoundException : Exception
|
||||
{
|
||||
public ChannelNotFoundException(string channelName)
|
||||
: base($"A channel with the name {channelName} could not be found.")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue