slightly more graceful error handling

This commit is contained in:
Adam R Grey 2023-03-02 00:10:49 -05:00
parent def4f3644e
commit c874e3e421

View File

@ -36,6 +36,9 @@ namespace silverworker_discord
{ {
string path = res.Data; string path = res.Data;
if (File.Exists(path)) if (File.Exists(path))
{
var bytesize = new System.IO.FileInfo(path).Length;
if(bytesize < 1024*1024*10)
{ {
try try
{ {
@ -43,8 +46,13 @@ namespace silverworker_discord
} }
catch (Exception e) catch (Exception e)
{ {
System.Console.Error.WriteLine(JsonConvert.SerializeObject(e)); System.Console.Error.WriteLine(e);
await message.Channel.SendMessageAsync($"aaaadam!\n{JsonConvert.SerializeObject(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); File.Delete(path);
} }