It is possible and not ideal to do this: (a vastly simplified example!)
[Serializable]
public class MyRecord
{
public string key {get; set;}
public
You can refactor your code this way:
public class Answer
{
public T result {get;set;}
public bool success {get;set;}
public string exception {get;set;}
}
public async Task> Get(string SomeKey)
{
var answer = new Answer();
try
{
if(ExistsInDB(SomeKey))
{
answer.result = await SomeRecordFromDB(SomeKey);
answer.success = true;
}
}
catch(Exception e)
{
answer.exception = e.Message;
}
return answer;
}