public async Task <DigipoolEntry[]> GetDigipool(int numberOfEntries) { try { var entryArray = await sqlDataAccess.GetDigipool(); foreach (var entry in entryArray) { SetPriority(entry); } return(entryArray.OrderBy(e => e.Priority) .ThenBy(e => e.TerminDigitalisierung) .ThenBy(e => e.OrderItemId) .Take(numberOfEntries) .ToArray()); } catch (SqlException ex) { Log.Error(ex, "SQL Server problem"); // Only really handle the case where connection could not be made if (ex.Errors[0].Number == 2 || ex.Errors[0].Number == 17142) { throw new OrderDatabaseNotFoundOrNotRunningException(); } throw; } }