Show an error when a bad import URL is given
This commit is contained in:
parent
8396e17a87
commit
d8503001eb
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
@ -25,7 +26,17 @@ namespace PluralKit.Bot.Commands
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
var response = await client.GetAsync(url);
|
||||
HttpResponseMessage response;
|
||||
try
|
||||
{
|
||||
response = await client.GetAsync(url);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
// Invalid URL throws this, we just error back out
|
||||
throw Errors.InvalidImportFile;
|
||||
}
|
||||
|
||||
if (!response.IsSuccessStatusCode) throw Errors.InvalidImportFile;
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user