Last change
on this file since 17526 was
17059,
checked in by mkommend, 5 years ago
|
#2839: Merged 16117, 16122, 16173, 16184, 16185, 16186, 16187, 16202, 16203, 16204, 16205, 16208, 16211, 16209, 16211, 16219, 16257, 16247 into stable.
|
File size:
1.4 KB
|
Rev | Line | |
---|
[15401] | 1 | using System;
|
---|
| 2 | using System.ServiceModel.Security;
|
---|
| 3 | using System.Threading.Tasks;
|
---|
| 4 | using HeuristicLab.PluginInfrastructure;
|
---|
| 5 |
|
---|
| 6 | namespace HeuristicLab.Clients.Hive {
|
---|
| 7 | public class SecurityExceptionUtil {
|
---|
| 8 | public static void TryAndReportSecurityExceptions(Action action, Action finallyCallback = null) {
|
---|
| 9 | try {
|
---|
| 10 | action();
|
---|
| 11 | } catch (MessageSecurityException ex) {
|
---|
| 12 | ErrorHandling.ShowErrorDialog("There is something wrong with the applied security. Are your credentials correct?", ex);
|
---|
| 13 | } catch (SecurityAccessDeniedException ex) {
|
---|
| 14 | ErrorHandling.ShowErrorDialog("The security authorization request failed. Are you a Hive administrator?", ex);
|
---|
| 15 | } finally {
|
---|
[16117] | 16 | if (finallyCallback != null) finallyCallback();
|
---|
[15401] | 17 | }
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | public static async Task TryAsyncAndReportSecurityExceptions(Action action, Action finallyCallback = null) {
|
---|
| 21 | try {
|
---|
| 22 | await Task.Run(action);
|
---|
| 23 | } catch (MessageSecurityException ex) {
|
---|
| 24 | ErrorHandling.ShowErrorDialog("There is something wrong with the applied security. Are your credentials correct?", ex);
|
---|
| 25 | } catch (SecurityAccessDeniedException ex) {
|
---|
| 26 | ErrorHandling.ShowErrorDialog("The security authorization request failed. Are you a Hive administrator?", ex);
|
---|
| 27 | } finally {
|
---|
[16117] | 28 | if (finallyCallback != null) finallyCallback();
|
---|
[15401] | 29 | }
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.