示例#1
0
        private void DeleteConfirmationDialog_Confirmed(object data)
        {
            // delete the device and reload the affected partition.
            UserGroupRowData userGroup = data as UserGroupRowData;

            try
            {
                _controller.DeleteUserGroup(userGroup, true);
            }
            catch (AuthorityGroupIsNotEmptyException ex)
            {
                DeleteNonEmptyGroupConfirmation.Data         = data;
                DeleteNonEmptyGroupConfirmation.Message      = String.Format(SR.AdminUserGroup_DeleteNonEmptyGroupDialog_AreYouSure, ExceptionTranslator.Translate(ex));
                DeleteNonEmptyGroupConfirmation.MessageType  = MessageBox.MessageTypeEnum.YESNO;
                DeleteNonEmptyGroupConfirmation.MessageStyle = "color: red; font-weight: bold";
                DeleteNonEmptyGroupConfirmation.Show();
            }
            catch (Exception ex)
            {
                DeleteErrorMessage.Message      = ExceptionTranslator.Translate(ex);
                DeleteErrorMessage.MessageStyle = "color: red; font-weight: bold";
                DeleteErrorMessage.MessageType  = MessageBox.MessageTypeEnum.ERROR;
                DeleteErrorMessage.Show();
            }
            UserGroupsPanel.UpdateUI();
        }
        public void When_Passed_A_Translatable_Fault_ToException_Returns_A_Generic_Exception()
        {
            var faultException = new FaultException<TestFault>(new TestFault(), "Test fault exception");
            var translator = new ExceptionTranslator();

            var result = translator.ToException(faultException);

            Assert.That(result, Is.TypeOf(typeof(TestException)));
        }
        public void When_Passed_A_Non_Typed_Fault_Exception_ToException_Returns_A_Generic_Exception()
        {
            var faultException = new FaultException("Test fault exception");
            var translator = new ExceptionTranslator();

            var result = translator.ToException(faultException);

            Assert.That(result, Is.TypeOf(typeof(System.Exception)));
        }
        public void When_Passed_A_Translatable_Exception_ToFaultException_Returns_A_Typed_Exception()
        {
            var exception = new TestException("This is an exception");
            var translator = new ExceptionTranslator();

            var result = translator.ToFaultException(exception);

            Assert.That(result, Is.TypeOf(typeof(FaultException<TestFault>)));
        }
        public void NonJsonServicesExceptionGetsInternalErrorCode()
        {
            var ex  = new InvalidOperationException();
            var err = new ExceptionTranslator().Translate(ex);

            Assert.NotNull(err);
            Assert.AreEqual(InternalErrorException.ErrorCode, err.Code);
            Assert.AreEqual(ex.Message, err.Message);
            Assert.AreEqual(ex.ToString(), err.Data);
        }
        public void ExceptionTranslatorCanOverrideMessage()
        {
            var ex  = new ParseErrorException();
            var err = new ExceptionTranslator().Translate(ex, message: "Nice try");

            Assert.NotNull(err);
            Assert.AreEqual(ex.Code, err.Code);
            Assert.AreEqual("Nice try", err.Message);
            Assert.AreEqual(ex.ToString(), err.Data);
        }
        public void ExceptionTranslatorCanOverrideCode()
        {
            var ex  = new ParseErrorException();
            var err = new ExceptionTranslator().Translate(ex, 123);

            Assert.NotNull(err);
            Assert.AreEqual(123, err.Code);
            Assert.AreEqual(ex.Message, err.Message);
            Assert.AreEqual(ex.ToString(), err.Data);
        }
        public void DefaultExceptionTranslatorCopyExceptionDataWithoutTranslation()
        {
            var ex  = new ParseErrorException();
            var err = new ExceptionTranslator().Translate(ex);

            Assert.NotNull(err);
            Assert.AreEqual(ex.Code, err.Code);
            Assert.AreEqual(ex.Message, err.Message);
            Assert.AreEqual(ex.ToString(), err.Data);
        }
示例#9
0
        public void TryToTranslateTest()
        {
            ExceptionTranslator target    = FWUtils.ExpLogUtils.ExceptionTranslator;
            Guid          msgGuid         = Guid.NewGuid();
            Exception     exception       = new Exception(msgGuid.ToString());
            string        expectedMessage = StringMsgs.Exceptions.UnknownExceptionHappened;
            UserException actual;

            actual = target.TryToTranslate(exception);
            Assert.AreEqual(expectedMessage, actual.Message);
        }
        public void When_Passed_A_Non_Translatable_Exception_ToFaultException_Returns_A_Generic_Exception()
        {
            var exception = new System.Exception("This is an exception");
            var translator = new ExceptionTranslator();

            var result = translator.ToFaultException(exception);

            Assert.That(result, Is.TypeOf(typeof(FaultException)));
            Assert.That(result.GetType().IsGenericType, Is.False);
            Assert.That(result.Message, Is.EqualTo("A fault occurred calling this service."));
        }
示例#11
0
        public override void OnException(HttpActionExecutedContext ctx)
        {
            HttpStatusCode    responseStatus = HttpStatusCode.InternalServerError;
            HttpExceptionData responseData   = new HttpExceptionData();

            ExceptionTranslator.TranslateException(ctx.Exception, ref responseStatus, ref responseData);

            if (!ShowStackTrace)
            {
                responseData.ErrorStackTrace = null;
            }

            ctx.Response = ctx.Request.CreateResponse(responseStatus, responseData);
        }
示例#12
0
        private void DeleteNonEmptyGroupConfirmationDialog_Confirmed(object data)
        {
            UserGroupRowData userGroup = data as UserGroupRowData;

            try
            {
                _controller.DeleteUserGroup(userGroup, false /* don't check if the group is empty. User has given the go head*/);
            }
            catch (Exception ex)
            {
                DeleteErrorMessage.Message      = ExceptionTranslator.Translate(ex);
                DeleteErrorMessage.MessageStyle = "color: red; font-weight: bold";
                DeleteErrorMessage.MessageType  = MessageBox.MessageTypeEnum.ERROR;
                DeleteErrorMessage.Show();
            }
            UserGroupsPanel.UpdateUI();
        }
示例#13
0
 public IActionResult CheckOutBooking(CheckOutBooking checkOutBooking)
 {
     if (ModelState.IsValid)
     {
         try
         {
             checkOutBooking.Id = checkOutBooking.BookingId;
             _domain.Dispatcher.SendCommand(checkOutBooking);
             return(RedirectToAction("BookingCheckOut", new { result = true, inProcess = true, errorMessage = "" }));
         }
         catch (Exception e)
         {
             _logger.LogInformation(ExceptionTranslator.TranslateException(e));
             return(RedirectToAction("BookingCheckOut", new { result = false, inProcess = true, errorMessage = ExceptionTranslator.TranslateException(e) }));
         }
     }
     return(RedirectToAction("BookingCheckOut", new { result = false, inProcess = true, errorMessage = "Invalid data" }));
 }
示例#14
0
 public void ExceptionTranslatorConstructorTest()
 {
     ExceptionTranslator target = new ExceptionTranslator();
 }
示例#15
0
 internal static void DefineException(java.lang.Class type, ExceptionTranslator dlg)
 {
     exceptionMap.put(type, dlg);
 }