public ArticleService(IUnitOfWork unitOfWork, IExceptionHandler exceptionHandler) { this.unitOfWork = unitOfWork; this.articleRepository = unitOfWork.ArticleRepository; this.articleVersionRepository = unitOfWork.ArticleVersionRepository; this.exceptionHandler = exceptionHandler; }
public ValueStack(IExceptionHandler handler, IExpressionContext expressionContext) { Values = new CustomDictionary(); _exceptionHandler = handler; _evaluator = expressionContext.CreateEvaluator(this); Persistables = new Dictionary<string, IPersistable>(); }
internal static Task NewMedia(INovaromaEngine engine, IExceptionHandler exceptionHandler, IDialogService dialogService, string searchQuery = null, string parentDirectory = null) { var viewModel = new NewMediaWizardViewModel(engine, exceptionHandler, dialogService); var t = viewModel.AddFromSearch(searchQuery, parentDirectory); new NewMediaWizard(viewModel).ForceShow(); return t; }
internal static Task AddFromImdbId(INovaromaEngine engine, IExceptionHandler exceptionHandler, IDialogService dialogService, string imdbId) { var viewModel = new NewMediaWizardViewModel(engine, exceptionHandler, dialogService); var t = viewModel.AddFromImdbId(imdbId); new NewMediaWizard(viewModel).ForceShow(); return t; }
/// <summary> /// Initializes a new instance of the <see cref="MobileDevicesEditor"/> class. /// </summary> /// <param name="synchronizationService">The synchronization service to be used /// for manipulating devices at the tracking service.</param> /// <param name="resourceProvider">The instance of resource provider for obtaining /// messages.</param> /// <param name="workingStatusController">The instance of the controller to be used /// for managing application status.</param> /// <param name="exceptionHandler">The exception handler for tracking service /// related errors.</param> /// <exception cref="ArgumentNullException"><paramref name="synchronizationService"/>, /// <paramref name="resourceProvider"/>, <paramref name="workingStatusController"/>, /// <paramref name="exceptionHandler"/> or <paramref name="project"/> is a null /// reference.</exception> public MobileDevicesEditor( ISynchronizationService synchronizationService, IWorkingStatusController workingStatusController, IExceptionHandler exceptionHandler, IProject project) { if (synchronizationService == null) { throw new ArgumentNullException("synchronizationService"); } if (workingStatusController == null) { throw new ArgumentNullException("workingStatusController"); } if (exceptionHandler == null) { throw new ArgumentNullException("exceptionHandler"); } if (project == null) { throw new ArgumentNullException("project"); } _synchronizationService = synchronizationService; _workingStatusController = workingStatusController; _exceptionHandler = exceptionHandler; _project = project; }
public DefaultApplicationConfigurationGetter( IExceptionHandler exceptionHandler, List<IHttpEndpoint> httpEndpoints) { _exceptionHandler = exceptionHandler; _httpEndpoints = httpEndpoints; }
public static void SetHandler(IExceptionHandler handler) { lock (_lock) { _handler = handler; } }
private static async Task<HttpResponseMessage> HandleAsyncCore(IExceptionHandler handler, ExceptionHandlerContext context, CancellationToken cancellationToken) { Contract.Assert(handler != null); Contract.Assert(context != null); await handler.HandleAsync(context, cancellationToken); IHttpActionResult result = context.Result; if (result == null) { return null; } HttpResponseMessage response = await result.ExecuteAsync(cancellationToken); if (response == null) { throw new InvalidOperationException(Error.Format(SRResources.TypeMethodMustNotReturnNull, typeof(IHttpActionResult).Name, "ExecuteAsync")); } return response; }
public PlayShellView(IEventAggregator eventBus, UserSettings settings, INotificationCenterMessageHandler handler, IDialogManager dialogManager, IExceptionHandler exceptionHandler) { InitializeComponent(); Loaded += (sender, args) => DialogHelper.MainWindowLoaded = true; _userSettings = settings; _handler = handler; _dialogManager = dialogManager; _exceptionHandler = exceptionHandler; _snow = new Snow(ContentCanvas, eventBus); WorkaroundSystemMenu_Init(); this.WhenActivated(d => { d(UserError.RegisterHandler<CanceledUserError>(x => CanceledHandler(x))); d(UserError.RegisterHandler<NotLoggedInUserError>(x => NotLoggedInDialog(x))); d(UserError.RegisterHandler<NotConnectedUserError>(x => NotConnectedDialog(x))); d(UserError.RegisterHandler<BusyUserError>(x => BusyDialog(x))); d(this.WhenAnyValue(x => x.ViewModel).BindTo(this, v => v.DataContext)); d(this.OneWayBind(ViewModel, vm => vm.Overlay.ActiveItem, v => v.MainScreenFlyout.ViewModel)); d(this.OneWayBind(ViewModel, vm => vm.SubOverlay, v => v.SubscreenFlyout.ViewModel)); d(this.OneWayBind(ViewModel, vm => vm.StatusFlyout, v => v.StatusFlyout.ViewModel)); d(this.WhenAnyObservable(x => x.ViewModel.ActivateWindows) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => DialogHelper.ActivateWindows(x))); d(_userSettings.AppOptions.WhenAnyValue(x => x.DisableEasterEggs) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(HandleEasterEgg)); d(TryCreateTrayIcon()); }); ThemeManager.IsThemeChanged += CustomThemeManager.ThemeManagerOnIsThemeChanged; }
protected HandleExceptionAndRetryActionDecorator(ITaskAction action, IExceptionHandler exceptionHandler) { RetryInterval = BackoffInterval.Default; _action = action; _exceptionHandler = exceptionHandler; }
public ConfigurationWindow(NovaromaEngine engine, IExceptionHandler exceptionHandler, IDialogService dialogService) { InitializeComponent(); _configurableEngine = engine; _engine = engine; _downloader = engine.Settings.Downloader.SelectedItem as IConfigurable; _exceptionHandler = exceptionHandler; _dialogService = dialogService; _initialMovieDir = engine.MovieDirectory; _initialTvShowDir = engine.TvShowDirectory; _engineSettings = engine.Settings; var utor = _downloader as UTorrentDownloader; if (utor != null && utor.IsAvailable) { _torrentSettings = utor.Settings; TorrentHowToHyperink.NavigateUri = new Uri(Properties.Resources.Url_HowToConfigureUtorrentWebUISettings); } else { var trantor = _downloader as TransmissionDownloader; if (trantor != null) { _torrentSettings = trantor.Settings; TorrentHowToHyperink.NavigateUri = new Uri(Properties.Resources.Url_HowToConfigureTransmissionWebUISettings); } } if (_torrentSettings == null) TorrentSettingsExpander.Visibility = Visibility.Collapsed; else if (_downloader != null) TorrentSettingsExpander.Tag = string.Format(Properties.Resources.TorrentWebUISettings, _downloader.SettingName); DataContext = this; Closing += OnClosing; }
public ExceptionHandledEventArgs(IExceptionHandler handler, Exception exception) { if(handler == null) throw new ArgumentNullException("handler"); this.Handler = handler; this.Exception = exception; }
public DownloadSearchViewModel(INovaromaEngine engine, IExceptionHandler exceptionHandler, IDialogService dialogService, IDownloadable downloadable, string directory) : base(dialogService) { _engine = engine; _exceptionHandler = exceptionHandler; _downloadable = downloadable; _directory = directory; _searchCommand = new RelayCommand(DoSearch, CanSearch); }
public LanguageService(IUnitOfWork unitOfWork, IExceptionHandler exceptionHandler, ILocalStorageService storageService, HttpContextBase context) { this.unitOfWork = unitOfWork; this.languageRepository = unitOfWork.LanguageRepository; this.exceptionHandler = exceptionHandler; this.storageService = storageService; this.context = context; }
public FeatureSnapshot(IExceptionHandler exceptionhandler) : base("snapshot", "control/feature-snapshot", "control/snapshot/action",true, exceptionhandler) { actionKey = wmisession.GetXenStoreItem("control/snapshot/action"); typeKey = wmisession.GetXenStoreItem("control/snapshot/type"); statusKey = wmisession.GetXenStoreItem("control/snapshot/status"); threadlock = new object(); }
public LastChanceExceptionHandler(IExceptionHandler innerHandler) { if (innerHandler == null) { throw Error.ArgumentNull("innerHandler"); } this.innerHandler = innerHandler; }
public ConsoleApplication(ICommandParser commandParser, IResultHandler resultHandler, IInput input, IExceptionHandler exceptionHandler) { _commandParser = commandParser; _resultHandler = resultHandler; _input = input; _exceptionHandler = exceptionHandler; }
public StepClassInvoker(StepType stepType, Type stepClass, KeyValuePair<string,object>[] supportedParameters, IExceptionHandler exceptionHandler) { if (!typeof(Step).IsAssignableFrom(stepClass)) throw new ArgumentException("The stepClass must inherit from Step", "stepClass"); _stepClass = stepClass; _exceptionHandler = exceptionHandler; Type = stepType; Name = new StepName(Type, _stepClass.Name, supportedParameters); Parameters = _stepClass.GetConstructors().Single().BindParameters(supportedParameters); }
/// <summary> /// Adds the exception intercept. /// </summary> /// <param name="builder">The builder.</param> /// <param name="exceptionIntercept">The exception intercept.</param> /// <returns></returns> public static IApplicationBuilder AddExceptionIntercept(this IApplicationBuilder builder, IExceptionHandler exceptionInspector) { var exceptionManager = builder.ApplicationServices.GetService<IExceptionInterceptManager>(); if (exceptionManager != null) { exceptionManager.AddExceptionIntercept(exceptionInspector); } return builder; }
public AuthFactory( IExceptionHandler exceptionHandler, ITwitterRequestHandler twitterRequestHandler, IOAuthWebRequestGenerator oAuthWebRequestGenerator, IJObjectStaticWrapper jObjectStaticWrapper) { _exceptionHandler = exceptionHandler; _twitterRequestHandler = twitterRequestHandler; _oAuthWebRequestGenerator = oAuthWebRequestGenerator; _jObjectStaticWrapper = jObjectStaticWrapper; }
internal HttpRouteExceptionHandler(ExceptionDispatchInfo exceptionInfo, IExceptionLogger exceptionLogger, IExceptionHandler exceptionHandler) { Contract.Assert(exceptionInfo != null); Contract.Assert(exceptionLogger != null); Contract.Assert(exceptionHandler != null); _exceptionInfo = exceptionInfo; _exceptionLogger = exceptionLogger; _exceptionHandler = exceptionHandler; }
public FeedbackWindow(IExceptionHandler exceptionHandler, ILogger logger, IDialogService dialogService, bool isFrown) { _exceptionHandler = exceptionHandler; _logger = logger; _dialogService = dialogService; _isFrown = isFrown; DataContext = this; InitializeComponent(); Loaded += OnLoaded; }
public WebTokenCreator( IExceptionHandler exceptionHandler, IOAuthWebRequestGenerator oAuthWebRequestGenerator, ICredentialsStore credentialsStore, ITwitterRequestHandler twitterRequestHandler) { _exceptionHandler = exceptionHandler; _oAuthWebRequestGenerator = oAuthWebRequestGenerator; _credentialsStore = credentialsStore; _twitterRequestHandler = twitterRequestHandler; }
public SubtitleSearchViewModel(INovaromaEngine engine, IExceptionHandler exceptionHandler, IDialogService dialogService, IDownloadable downloadable, FileInfo fileInfo) : base(dialogService) { _engine = engine; _exceptionHandler = exceptionHandler; _downloadable = downloadable; _fileInfo = fileInfo; _subtitleLanguages = new MultiCheckSelection<EnumInfo<Language>>(Constants.LanguagesEnumInfo); foreach (var subtitleLanguage in engine.SubtitleLanguages) _subtitleLanguages.Selections.First(s => s.Item.Item == subtitleLanguage).IsSelected = true; _searchCommand = new RelayCommand(DoSearch, CanSearch); }
public ProductManager( IExceptionHandler exceptionHandler, IProductValidator productValidator, IProductRepository productRepository, IProductFactory productFactory) { _exceptionHandler = exceptionHandler; _productValidator = productValidator; _productRepository = productRepository; _productFactory = productFactory; }
public WebTokenCreator( IExceptionHandler exceptionHandler, IFactory<ITemporaryCredentials> applicationCredentialsUnityFactory, IOAuthWebRequestGenerator oAuthWebRequestGenerator, ITwitterRequestHandler twitterRequestHandler) { _exceptionHandler = exceptionHandler; _applicationCredentialsUnityFactory = applicationCredentialsUnityFactory; _oAuthWebRequestGenerator = oAuthWebRequestGenerator; _twitterRequestHandler = twitterRequestHandler; }
public WebRequestExecutor( IExceptionHandler exceptionHandler, IHttpClientWebHelper httpClientWebHelper, IFactory<IWebRequestResult> webRequestResultFactory, IFactory<ITwitterTimeoutException> twitterTimeoutExceptionFactory) { _exceptionHandler = exceptionHandler; _httpClientWebHelper = httpClientWebHelper; _webRequestResultFactory = webRequestResultFactory; _twitterTimeoutExceptionFactory = twitterTimeoutExceptionFactory; }
/// <summary> /// Initializes a new instance of the <see cref="AuthenticationService"/> class. /// </summary> /// <param name="settings">The settings.</param> /// <param name="eventAggregator">The event aggregator.</param> /// <param name="exceptionHandler">The exception handler.</param> /// <param name="sessionService">The session service.</param> public AuthenticationService(ISettings settings, IEventAggregator eventAggregator, IExceptionHandler exceptionHandler, ISessionService sessionService) { Guard.AgainstNullArgument("settings", settings); Guard.AgainstNullArgument("eventAggregator", eventAggregator); Guard.AgainstNullArgument("exceptionHandler", exceptionHandler); Guard.AgainstNullArgument("sessionService", sessionService); this._settings = settings; this._eventAggregator = eventAggregator; this._exceptionHandler = exceptionHandler; this._sessionService = sessionService; }
public void Before_Each_Test() { _sensorReaderMock = new Mock<ISensorReader>(); _loggerMock = new Mock<ILogger>(); _exceptionHandler = new ExceptionHandler(_loggerMock.Object); _verifierMock = new Mock<IPlantReadingsVerifier>(); Instance = new PlantReadingsManager( _sensorReaderMock.Object, _exceptionHandler, _verifierMock.Object); }
private static bool CheckExceptionHandler(IExceptionHandler o, IExceptionHandler n) { if (o.CatchType.ToString() != n.CatchType.ToString() || o.FilterOffset != n.FilterOffset || o.HandlerLength != n.HandlerLength || o.HandlerOffset != n.HandlerOffset || o.TryLength != n.TryLength || o.TryOffset != n.TryOffset || o.Type != n.Type ) { return false; } return true; }
/// <summary> /// Return a list of resources which this user is allowed to install from DBL. /// If we cannot contact DBL, return an empty list. /// </summary> /// <param name="userSecret">The user secret.</param> /// <param name="paratextOptions">The paratext options.</param> /// <param name="restClientFactory">The rest client factory.</param> /// <param name="fileSystemService">The file system service.</param> /// <param name="jwtTokenHelper">The JWT token helper.</param> /// <param name="baseUrl">The base URL.</param> /// <returns>The Installable Resources.</returns> /// <exception cref="ArgumentNullException">restClientFactory /// or /// userSecret</exception> /// <remarks>Tests on this method can be found in ParatextServiceTests.cs calling GetResources().</remarks> public static IEnumerable <SFInstallableDblResource> GetInstallableDblResources(UserSecret userSecret, ParatextOptions paratextOptions, ISFRestClientFactory restClientFactory, IFileSystemService fileSystemService, IJwtTokenHelper jwtTokenHelper, IExceptionHandler exceptionHandler, string baseUrl = null) { // Parameter check (just like the constructor) if (restClientFactory == null) { throw new ArgumentNullException(nameof(restClientFactory)); } else if (userSecret == null) { throw new ArgumentNullException(nameof(userSecret)); } ISFRestClient client = restClientFactory.Create(string.Empty, userSecret); baseUrl = string.IsNullOrWhiteSpace(baseUrl) ? InternetAccess.ParatextDBLServer : baseUrl; string response = null; try { response = client.Get(BuildDblResourceEntriesUrl(baseUrl)); } catch (WebException e) { // If we get a temporary 401 Unauthorized response, return an empty list. string errorExplanation = "GetInstallableDblResources failed when attempting to inquire about" + $" resources and is ignoring error {e}"; var report = new Exception(errorExplanation); // Report to bugsnag, but don't throw. exceptionHandler.ReportException(report); return(Enumerable.Empty <SFInstallableDblResource>()); } IEnumerable <SFInstallableDblResource> resources = ConvertJsonResponseToInstallableDblResources(baseUrl, response, restClientFactory, fileSystemService, jwtTokenHelper, DateTime.Now, userSecret, paratextOptions, new ParatextProjectDeleter(), new ParatextMigrationOperations(), new ParatextZippedResourcePasswordProvider(paratextOptions)); return(resources); }
public ResourceController(ResourceRepository context, ILogHandler logHandler, IExceptionHandler exceptionHandler) { this.context = context; this.logHandler = logHandler; this.exceptionHandler = exceptionHandler; }
//------------------------------------------------------------------------------ // // Method: MetricLoggerStorer (constructor) // //------------------------------------------------------------------------------ /// <summary> /// Initialises a new instance of the ApplicationMetrics.MetricLoggerStorer class. Note this is an additional constructor to facilitate unit tests, and should not be used to instantiate the class under normal conditions. /// </summary> /// <param name="bufferProcessingStrategy">Object which implements a processing strategy for the buffers (queues).</param> /// <param name="intervalMetricChecking">Specifies whether an exception should be thrown if the correct order of interval metric logging is not followed (e.g. End() method called before Begin()).</param> /// <param name="dateTime">A test (mock) DateTime object.</param> /// <param name="exceptionHandler">A test (mock) exception handler object.</param> protected MetricLoggerStorer(IBufferProcessingStrategy bufferProcessingStrategy, bool intervalMetricChecking, IDateTime dateTime, IExceptionHandler exceptionHandler) : base(bufferProcessingStrategy, intervalMetricChecking, dateTime, exceptionHandler) { InitialisePrivateMembers(); }
public RequestExceptionMiddleware(IExceptionHandler exceptionHandler) { Guard.NotNull(exceptionHandler); this.exceptionHandler = exceptionHandler; }
public static async Task <TReturn> HandleExceptionWithNullCheck <TReturn>(Func <CancellationToken, Task <TReturn> > funcToExecute, CancellationToken funcCancellationToken = default(CancellationToken), IExceptionHandler exceptionHandler = null, Func <CancellationToken, Task> onExceptionCompensatingHandler = null, CancellationToken onExceptionCompensatingHandlerCancellationToken = default(CancellationToken)) { if (exceptionHandler.IsNotNull()) { return(await exceptionHandler.HandleExceptionAsync(funcToExecute, funcCancellationToken, onExceptionCompensatingHandler, onExceptionCompensatingHandlerCancellationToken)); } else { return(await funcToExecute(funcCancellationToken)); } }
internal static Step InstanceFor(ScenarioBase scenario, Type stepClass, KeyValuePair <string, object>[] parameters, IExceptionHandler exceptionHandler) { var instance = (Step)Activator.CreateInstance(stepClass, parameters.Select(p => p.Value).ToArray()); instance.SetScenario(scenario, exceptionHandler); return(instance); }
public ExceptionLogger(IExceptionHandler handler) { _handler = handler; }
public LoyaltyRedemptionServiceRefactored(ILoyaltyDataService service, IExceptionHandler exceptionHandler, ITransactionManager transactionManager) { _loyaltyDataService = service; _exceptionHandler = exceptionHandler; _transactionManager = transactionManager; }
public HttpCommunicationClientFactory(HttpClient httpClient, IExceptionHandler exceptionHandler) : base(exceptionHandlers: new[] { exceptionHandler }) { this.httpClient = httpClient; }
/// <summary> /// This constructor may call virtual methods. /// </summary> protected BaseApplicationInstanceIdRenter(IServiceProvider serviceProvider) { // We use the service locator anti-pattern here, to hide the internal dependencies (registered by our own extension methods), enabling subclasses from third-party implementations this.ExceptionHandler = serviceProvider.GetRequiredService <IExceptionHandler>(); }
internal static async Task <bool> CopyErrorResponseAsync(ExceptionContextCatchBlock catchBlock, HttpContextBase httpContextBase, HttpRequestMessage request, HttpResponseMessage response, Exception exception, IExceptionLogger exceptionLogger, IExceptionHandler exceptionHandler, CancellationToken cancellationToken) { Contract.Assert(httpContextBase != null); Contract.Assert(httpContextBase.Response != null); Contract.Assert(request != null); Contract.Assert(exception != null); Contract.Assert(catchBlock != null); Contract.Assert(catchBlock.CallsHandler); HttpResponseBase httpResponseBase = httpContextBase.Response; HttpResponseMessage errorResponse = null; HttpResponseException responseException = exception as HttpResponseException; // Ensure all headers and content are cleared to eliminate any partial results. ClearContentAndHeaders(httpResponseBase); // If the exception we are handling is HttpResponseException, // that becomes the error response. if (responseException != null) { errorResponse = responseException.Response; } else { ExceptionContext exceptionContext = new ExceptionContext(exception, catchBlock, request) { Response = response }; await exceptionLogger.LogAsync(exceptionContext, cancellationToken); errorResponse = await exceptionHandler.HandleAsync(exceptionContext, cancellationToken); if (errorResponse == null) { return(false); } } Contract.Assert(errorResponse != null); if (!await CopyResponseStatusAndHeadersAsync(httpContextBase, request, errorResponse, exceptionLogger, cancellationToken)) { // Don't rethrow the original exception unless explicitly requested to do so. In this case, the // exception handler indicated it wanted to handle the exception; it simply failed create a stable // response to send. return(true); } // The error response may return a null content if content negotiation // fails to find a formatter, or this may be an HttpResponseException without // content. In either case, cleanup and return a completed task. if (errorResponse.Content == null) { errorResponse.Dispose(); return(true); } CopyHeaders(errorResponse.Content.Headers, httpContextBase); await WriteErrorResponseContentAsync(httpResponseBase, request, errorResponse, cancellationToken, exceptionLogger); return(true); }
private UnitOfWork GetTargetWith(IDbContextUtilities contextUtilitiesStub, IInterceptorsResolver interceptorsResolver, Mock <DbContext> contextStub, IExceptionHandler handler) { var contextFactoryStub = contextStub.BuildFactoryStub(); return(new UnitOfWork(contextFactoryStub, interceptorsResolver, contextUtilitiesStub, handler)); }
public static TReturn HandleExceptionWithNullCheck <TReturn>(Func <TReturn> actionToExecute, IExceptionHandler exceptionHandler = null, Action onExceptionCompensatingHandler = null) { if (exceptionHandler.IsNotNull()) { return(exceptionHandler.HandleException(actionToExecute, onExceptionCompensatingHandler)); } else { return(actionToExecute()); } }
void SetScenario(ScenarioBase scenario, IExceptionHandler exceptionHandler) { _scenario = scenario; _exceptionHandler = exceptionHandler; }
/// <summary> /// Checks the resource permission. /// </summary> /// <param name="id">The identifier.</param> /// <param name="userSecret">The user secret.</param> /// <param name="paratextOptions">The paratext options.</param> /// <param name="restClientFactory">The rest client factory.</param> /// <param name="fileSystemService">The file system service.</param> /// <param name="jwtTokenHelper">The JWT token helper.</param> /// <param name="baseUrl">The base URL.</param> /// <returns> /// <c>true</c> if the user has permission to access the resource; otherwise, <c>false</c>. /// </returns> /// <exception cref="ArgumentNullException">id /// or /// userSecret /// or /// restClientFactory</exception> public static bool CheckResourcePermission(string id, UserSecret userSecret, ParatextOptions paratextOptions, ISFRestClientFactory restClientFactory, IFileSystemService fileSystemService, IJwtTokenHelper jwtTokenHelper, IExceptionHandler exceptionHandler, string baseUrl = null) { // Parameter check if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException(nameof(id)); } else if (userSecret == null) { throw new ArgumentNullException(nameof(userSecret)); } else if (restClientFactory == null) { throw new ArgumentNullException(nameof(restClientFactory)); } ISFRestClient client = restClientFactory.Create(string.Empty, userSecret); baseUrl = string.IsNullOrWhiteSpace(baseUrl) ? InternetAccess.ParatextDBLServer : baseUrl; try { _ = client.Head(BuildDblResourceEntriesUrl(baseUrl, id)); return(true); } catch (Exception ex) { // Normally we would catch the specific WebException, // but something in ParatextData is interfering with it. if (ex.InnerException?.Message.StartsWith("401: ", StringComparison.OrdinalIgnoreCase) ?? false) { // A 401 error means unauthorized (probably a bad token) return(false); } else if (ex.InnerException?.Message.StartsWith("403: ", StringComparison.OrdinalIgnoreCase) ?? false) { // A 403 error means no access. return(false); } else if (ex.InnerException?.Message.StartsWith("404: ", StringComparison.OrdinalIgnoreCase) ?? false) { // A 404 error means that the resource is not on the server return(false); } else if (ex.InnerException?.Message.StartsWith("405: ", StringComparison.OrdinalIgnoreCase) ?? false) { // A 405 means that HEAD request does not work on the server, so we will use the resource list // This is slower (although faster than a GET request on the resource), but more reliable IEnumerable <SFInstallableDblResource> resources = GetInstallableDblResources( userSecret, paratextOptions, restClientFactory, fileSystemService, jwtTokenHelper, exceptionHandler, baseUrl); return(resources.Any(r => r.DBLEntryUid.Id == id)); } else if (ex.Source == "NSubstitute") { // This occurs during unit tests to test whether there is permission or not return(false); } else { // An unknown error throw; } } }
public DARController(IDARService DarService, IUserTeamService UserTeamService, ITasksService TaskService, IExceptionHandler Exception) { _DarService = DarService; _UserTeamService = UserTeamService; _TaskService = TaskService; _exception = Exception; }
public void HandleExceptionsWith(IExceptionHandler <object> exceptionHandler) { _exceptionHandler = exceptionHandler; }
public JobOrderHeaderController(IJobOrderHeaderService PurchaseOrderHeaderService, IExceptionHandler exec, IDocumentTypeService DocumentTypeServ, IJobOrderSettingsService JobOrderSettingsServ, IPerkService perkServ, IPerkDocumentTypeService perkDocTypeServ, IDocumentValidation DocValidation, ICostCenterService costCenterSer) { _JobOrderHeaderService = PurchaseOrderHeaderService; _exception = exec; _documentTypeService = DocumentTypeServ; _jobOrderSettingsServie = JobOrderSettingsServ; _perkService = perkServ; _perkDocumentTypeService = perkDocTypeServ; _documentValidation = DocValidation; _costCenterService = costCenterSer; UserRoles = (List <string>)System.Web.HttpContext.Current.Session["Roles"]; }
/// <summary> /// Constructor of DBservice /// </summary> /// <param name="connectionString">string</param> /// <param name="providerFactory">DbProviderFactory</param> /// <param name="logger">ILogger</param> /// <param name="exceptionHandler">IExceptionHandler</param> public DBService(string connectionString, DbProviderFactory providerFactory, Kotacs.Libraries.Common.Logging.ILogger logger, IExceptionHandler exceptionHandler) : base(connectionString, providerFactory) { this.Logger = logger; this.ExceptionHandler = exceptionHandler; this.cplDatabase = new CplDatabase(); //CreatePerformanceCounters(); }
public static void Init( IApplicationLog applicationLog, Func <ILogWriter, IApplicationWatchdog> initWatchdog, Func <ILogWriter, IExceptionHandler> initExceptionHandler, Func <ILogWriter, IAgentIdentity> initAgentIdentity, Func <ILogWriter, IAgentIdentity, ISettingsProvider> initSettingsProvider, Action <ISettingsProvider, IApplicationLog, IAgentIdentity> initApplicationLog, Func <IExceptionHandler, ILogWriter, ISettingsProvider, IAgentIdentity, IApplicationWatchdog, IApplicationServiceBus> loadServiceBus, Action onShutDown) { if (applicationLog == null) { throw new ArgumentNullException("applicationLog"); } if (initWatchdog == null) { throw new ArgumentNullException("initWatchdog"); } if (initApplicationLog == null) { throw new ArgumentNullException("initApplicationLog"); } if (initExceptionHandler == null) { throw new ArgumentNullException("initExceptionHandler"); } if (initSettingsProvider == null) { throw new ArgumentNullException("initSettingsProvider"); } if (initAgentIdentity == null) { throw new ArgumentNullException("initAgentIdentity"); } if (onShutDown == null) { throw new ArgumentNullException("onShutDown"); } if (loadServiceBus == null) { throw new ArgumentNullException("loadServiceBus"); } _onShutDown = onShutDown; IApplicationWatchdog watchdog = initWatchdog(applicationLog); watchdog.BeatDog(); _exceptionHandler = initExceptionHandler(applicationLog); _agentIdentity = initAgentIdentity(applicationLog); applicationLog.AddEntry( new LogEntry( MessageLevel.AppLifecycle, ThisClassName, string.Format("Agent {0} started.", _agentIdentity.ID))); _settingsProvider = initSettingsProvider(applicationLog, _agentIdentity); initApplicationLog(_settingsProvider, applicationLog, _agentIdentity); _applicationLog = applicationLog; _serviceBus = loadServiceBus(_exceptionHandler, applicationLog, _settingsProvider, _agentIdentity, watchdog); _settingsProvider.SettingsChanged += SettingsProvider_SettingsChanged; }
public ExceptionAttribute(IExceptionHandler handler) { _ExceptionHandler = handler; }
public PropertyHeaderController(IPropertyHeaderService PropertyHeaderService, IExceptionHandler exec, IDocumentTypeService DocumentTypeServ, IDocumentValidation DocValidation, IProcessService ProcessService) { _PropertyHeaderService = PropertyHeaderService; _exception = exec; _documentTypeService = DocumentTypeServ; _documentValidation = DocValidation; _ProcessService = ProcessService; UserRoles = (List <string>)System.Web.HttpContext.Current.Session["Roles"]; }
public ExceptionFilter(IExceptionHandler exceptionHandler, ILoggerFactory loggerFactory) { _exceptionHandler = exceptionHandler ?? throw new ArgumentNullException(nameof(exceptionHandler)); _logger = loggerFactory?.CreateLogger <ExceptionFilter>() ?? throw new ArgumentNullException(nameof(loggerFactory)); }
public HttpContextCacheAdapter(HttpContextBase context, IExceptionHandler exceptionHandler) { this.context = context; this.exceptionHandler = exceptionHandler; }
internal static async Task CopyResponseAsync(HttpContextBase httpContextBase, HttpRequestMessage request, HttpResponseMessage response, IExceptionLogger exceptionLogger, IExceptionHandler exceptionHandler, CancellationToken cancellationToken) { Contract.Assert(httpContextBase != null); Contract.Assert(request != null); // A null response creates a 500 with no content if (response == null) { SetEmptyErrorResponse(httpContextBase.Response); return; } if (!await CopyResponseStatusAndHeadersAsync(httpContextBase, request, response, exceptionLogger, cancellationToken)) { return; } // TODO 335085: Consider this when coming up with our caching story if (response.Headers.CacheControl == null) { // DevDiv2 #332323. ASP.NET by default always emits a cache-control: private header. // However, we don't want requests to be cached by default. // If nobody set an explicit CacheControl then explicitly set to no-cache to override the // default behavior. This will cause the following response headers to be emitted: // Cache-Control: no-cache // Pragma: no-cache // Expires: -1 httpContextBase.Response.Cache.SetCacheability(HttpCacheability.NoCache); } // Asynchronously write the response body. If there is no body, we use // a completed task to share the Finally() below. // The response-writing task will not fault -- it handles errors internally. if (response.Content != null) { await WriteResponseContentAsync(httpContextBase, request, response, exceptionLogger, exceptionHandler, cancellationToken); } }
public static async Task HandleExceptionWithNullCheck(Func <CancellationToken, Task> actionToExecute, CancellationToken actionCancellationToken = default(CancellationToken), IExceptionHandler exceptionHandler = null, Func <CancellationToken, Task> onExceptionCompensatingHandler = null, CancellationToken onExceptionCompensatingHandlerCancellationToken = default(CancellationToken)) { if (exceptionHandler.IsNotNull()) { await exceptionHandler.HandleExceptionAsync(actionToExecute, actionCancellationToken, onExceptionCompensatingHandler, onExceptionCompensatingHandlerCancellationToken); } else { await actionToExecute(actionCancellationToken); } }
public WordAudioExceptionHandler(IExceptionHandler successor) { this.successor = successor; }
/// <summary> /// Specify an exception handler to be used for event handlers and worker pools created by this disruptor. /// The exception handler will be used by existing and future event handlers and worker pools created by this disruptor instance. /// </summary> /// <param name="exceptionHandler">the exception handler to use</param> public void SetDefaultExceptionHandler(IExceptionHandler <T> exceptionHandler) { CheckNotStarted(); ((ExceptionHandlerWrapper <T>)_exceptionHandler).SwitchTo(exceptionHandler); }
public CommandElasticSearchableRepository(ICommand <TEntity> command, IExceptionHandler exceptionHandler) : base(command, exceptionHandler) { }
private static Task WriteResponseContentAsync(HttpContextBase httpContextBase, HttpRequestMessage request, HttpResponseMessage response, IExceptionLogger exceptionLogger, IExceptionHandler exceptionHandler, CancellationToken cancellationToken) { Contract.Assert(httpContextBase != null); Contract.Assert(response != null); Contract.Assert(request != null); Contract.Assert(response.Content != null); HttpResponseBase httpResponseBase = httpContextBase.Response; HttpContent responseContent = response.Content; CopyHeaders(responseContent.Headers, httpContextBase); // PrepareHeadersAsync already evaluated the buffer policy. bool isBuffered = httpResponseBase.BufferOutput; return(isBuffered ? WriteBufferedResponseContentAsync(httpContextBase, request, response, exceptionLogger, exceptionHandler, cancellationToken) : WriteStreamedResponseContentAsync(httpContextBase, request, response, exceptionLogger, cancellationToken)); }