slightly more graceful error handling
This commit is contained in:
parent
def4f3644e
commit
c874e3e421
12
Features.cs
12
Features.cs
@ -36,6 +36,9 @@ namespace silverworker_discord
|
||||
{
|
||||
string path = res.Data;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var bytesize = new System.IO.FileInfo(path).Length;
|
||||
if(bytesize < 1024*1024*10)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -43,8 +46,13 @@ namespace silverworker_discord
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Console.Error.WriteLine(JsonConvert.SerializeObject(e));
|
||||
await message.Channel.SendMessageAsync($"aaaadam!\n{JsonConvert.SerializeObject(e)}");
|
||||
System.Console.Error.WriteLine(e);
|
||||
await message.Channel.SendMessageAsync($"aaaadam!\n{e}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"file appears too big ({bytesize} bytes ({bytesize / (1024*1024)}MB)), not posting");
|
||||
}
|
||||
File.Delete(path);
|
||||
}
|
||||
|
Reference in New Issue
Block a user