Skip to content

Instantly share code, notes, and snippets.

@FraukeN
Last active June 15, 2018 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FraukeN/c700e1fb9973cf8e51c957299ade1f58 to your computer and use it in GitHub Desktop.
Save FraukeN/c700e1fb9973cf8e51c957299ade1f58 to your computer and use it in GitHub Desktop.
OverviewVM new LoadData with exception handling
public OverviewVM(IRepository<ToDoItem> toDoRepo)
{
_toDoRepo = toDoRepo ?? throw new ArgumentNullException("toDoRepo");
IsFaulted = false;
ErrorMessage = string.Empty;
}
public async Task LoadData()
{
try
{
ToDoItems = await _toDoRepo.GetAsync();
IsFaulted = false;
ErrorMessage = string.Empty;
}
catch (Exception)
{
IsFaulted = true;
ErrorMessage = "Unable to Load ToDo Items";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment