Serialize an object to json and print an error to a file if that is not possible
public async Task<string> Get(object obj) { try { return JsonConvert.SerializeObject(obj); } catch (Exception ex) { await File.WriteAllTextAsync(@"C:\log.txt", ex.Message); throw; } }