public void ErroSql(string queryString, Hashtable paramsList, BaseException exe) { string @params = "["; int contador = 0; if ((paramsList == null)) { @params = ""; } else { foreach (string parametro in paramsList.Keys) { if ((paramsList[parametro] == null)) { @params = @params + parametro + " = null"; } else { @params = @params + parametro + " = " + paramsList[parametro].ToString(); } if ((contador != paramsList.Count - 1)) { @params = @params + ", "; } contador += 1; } @params = @params + "]"; } Erro("Erro ao executar query: " + queryString + " " + @params, exe); }
internal async Task <JsonResult> ExceptionLog(BaseException baseExec) { SqlConnection cn = null; try { cn = Connection.GetConnection(); SqlDataAdapter smd = new SqlDataAdapter("exception_application_log_insert", cn); smd.SelectCommand.CommandType = CommandType.StoredProcedure; smd.SelectCommand.Parameters.AddWithValue("@Exception", baseExec.Exception); smd.SelectCommand.Parameters.AddWithValue("@ExceptionType", baseExec.ExceptionType); smd.SelectCommand.Parameters.AddWithValue("@fragment", baseExec.fragment); smd.SelectCommand.Parameters.AddWithValue("@lineNo", baseExec.lineNo); smd.SelectCommand.Parameters.AddWithValue("@method", baseExec.method); DataTable dt = new DataTable(); smd.Fill(dt); smd.Dispose(); return(new JsonResult(dt)); } catch (Exception) { throw; } finally { Connection.CloseConnection(ref cn); } }
protected void LogException(BaseException ex, string className, string methodName, string currentUserName, bool isBusinessLogEnable) { if (ex.InsertedLog) { return; } ex.InsertedLog = true; string curentUsername = currentUserName; if (curentUsername.ToLower().Equals("nunituser")) { return; } if (isBusinessLogEnable) { if (ex is InvalidPersianDateException) { businessErrorlogger.Error(curentUsername, className, methodName, "BaseGTSBusiness", " InvalidPersianDateException --> " + ((InvalidPersianDateException)ex).GetLogMessage(), ex); } else if (ex is UIBaseException) { businessErrorlogger.Error(curentUsername, className, methodName, "BaseGTSBusiness", String.Format("{0} --> {1}", ex.GetType().Name, ((UIBaseException)ex).GetLogMessage()), ex); } else { businessErrorlogger.Error(curentUsername, className, methodName, "BaseGTSBusiness", String.Format("{0} --> {1}", ex.GetType().Name, ((BaseException)ex).GetLogMessage()), ex); } } }
/// <summary>プロジェクトの異常処理</summary> void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { if (e.Exception is DBException) { DBException ex = (DBException)e.Exception; LogInfo.WriteErrorLog(ex.MessageID, ex); LogInfo.WriteFatalLog(ex.InnerException); CommonDialog.ShowErrorDialog(ex.MessageID); } else if (e.Exception is FileException) { FileException ex = (FileException)e.Exception; LogInfo.WriteErrorLog(ex.MessageID, ex.InnerException); CommonDialog.ShowErrorDialog(ex.MessageID); } else if (e.Exception is BaseException) { BaseException ex = (BaseException)e.Exception; LogInfo.WriteErrorLog(ex.MessageID, ex.InnerException); CommonDialog.ShowErrorDialog(ex.MessageID); } else { LogInfo.WriteErrorLog(Consts.SYSERR_003, e.Exception); CommonDialog.ShowErrorDialog(Consts.SYSERR_003); } e.Handled = true; }
public BaseException Delete(int id) { var baseException = new BaseException(); try { var dbItem = _db.RecipeIngredients.FirstOrDefault(user => user.Id == id); _db.Entry(dbItem).State = EntityState.Modified; if (dbItem != null) { dbItem.DateModified = DateTime.UtcNow; dbItem.IsDeleted = true; baseException.Id = dbItem.Id; } _db.SaveChanges(); baseException.HasError = true; baseException.HasError = false; } catch (Exception e) { baseException.HasError = true; baseException.Message = e.Message; } return(baseException); }
public async override void OnException(ExceptionContext context) { var baseEx = new BaseException("", context.Exception.Message, context.Exception); try { if (context.Exception is BaseException) { baseEx = context.Exception as CotorraNode.Common.ManageException.BaseException; } var message = baseEx.Message; if (baseEx.Message.Contains("One or more errors occurred. (")) { message = message.Replace("One or more errors occurred. (", ""); message = message.Replace("})", "}"); message = message.Replace(")", ""); } baseEx = new BaseException(baseEx.Code, message, baseEx); } catch (Exception ex) { baseEx = new BaseException(baseEx.Code, ex.Message, baseEx); } context.Result = new JsonResult(CotorraNode.App.Common.UX.Tools.GetMessageFromException(baseEx)); }
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { MessageBoxResult result; Exception exception = (Exception)e.ExceptionObject; if (exception is DBException) { DBException ex = (DBException)exception; LogInfo.WriteErrorLog(ex.MessageID, ex); LogInfo.WriteFatalLog(ex.InnerException); result = CommonDialog.ShowErrorDialog(ex.MessageID); } else if (exception is FileException) { FileException ex = (FileException)exception; LogInfo.WriteErrorLog(ex.MessageID, ex.InnerException); result = CommonDialog.ShowErrorDialog(ex.MessageID); } else if (exception is BaseException) { BaseException ex = (BaseException)exception; LogInfo.WriteErrorLog(ex.MessageID, ex.InnerException); result = CommonDialog.ShowErrorDialog(ex.MessageID); } else { LogInfo.WriteErrorLog(Consts.SYSERR_003, exception); result = CommonDialog.ShowErrorDialog(Consts.SYSERR_003); } if (result == MessageBoxResult.OK) { Environment.Exit(ERROR_EXIT_CODE); } }
/// <summary> /// BaseException 日志 /// </summary> /// <param name="ex"></param> public static void BaseExceptionLog(BaseException ex) { if (!Config.IsDebug) { return; } LogBegin("[[BaseException]]"); Log(ex.GetType().Name); Log("Message:{0}", ex.Message); Log("StackTrace:{0}", ex.StackTrace); if (ex.InnerException != null) { Log("InnerException:{0}", ex.InnerException.Message); Log("InnerException.StackTrace:{0}", ex.InnerException.StackTrace); } if (OnBaseExceptionFunc != null) { try { OnBaseExceptionFunc(ex); } catch { } } LogEnd(); }
public void ExceptionTest() { string errorType = "SDB_DMS_EOC"; BaseException ex = new BaseException(errorType); Assert.IsTrue(ex.Message.ToString().Equals("End of collection")); }
private static Task HandleExceptionAsync(HttpContext context, BaseException ex) { var code = HttpStatusCode.InternalServerError; switch (ex) { case NotFoundException _: code = HttpStatusCode.NotFound; break; case ForbiddenException _: code = HttpStatusCode.Forbidden; break; case ValidationException _: code = HttpStatusCode.BadRequest; break; case UnauthorizedException _: code = HttpStatusCode.Unauthorized; break; } var result = string.Empty; if (!string.IsNullOrEmpty(ex.Message)) { result = JsonConvert.SerializeObject(ex.ErrorResponse); } context.Response.ContentType = "application/json"; context.Response.StatusCode = (int)code; return(context.Response.WriteAsync(result)); }
private static Task HandleExceptionAsync(HttpContext context, BaseException exception) { GlobalDiagnosticsContext.Set("configDir", Path.Combine(Directory.GetCurrentDirectory(), "NLogFile")); string logConfigPath = string.Empty; if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { logConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "nlog.Development.config"); } else { logConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "nlog.config"); } var logger = NLogBuilder.ConfigureNLog(logConfigPath).GetCurrentClassLogger(); logger.Log(LogLevel.Error, exception, exception.Description); Response response = new Response() { Message = exception.Description, ErrMsg = exception.Message, Status = exception.Code.ToString() }; var result = JsonConvert.SerializeObject(response); context.Response.ContentType = "application/json"; return(context.Response.WriteAsync(result)); }
public void BaseException_with_message_and_inner_exception() { var e = new BaseException(Message, InnerException); Assert.AreEqual(Message, e.Message); Assert.AreSame(InnerException, e.InnerException); }
public void Function() { Eplan.EplApi.Base.BaseException bexAssert = new BaseException("Assert", MessageLevel.Assert); bexAssert.FixMessage(); Eplan.EplApi.Base.BaseException bexError = new BaseException("Error", MessageLevel.Error); bexError.FixMessage(); Eplan.EplApi.Base.BaseException bexFatalError = new BaseException("FatalError", MessageLevel.FatalError); bexFatalError.FixMessage(); Eplan.EplApi.Base.BaseException bexMessage = new BaseException("Message", MessageLevel.Message); bexMessage.FixMessage(); Eplan.EplApi.Base.BaseException bexTrace = new BaseException("Trace", MessageLevel.Trace); bexTrace.FixMessage(); Eplan.EplApi.Base.BaseException bexWarning = new BaseException("Warning", MessageLevel.Warning); bexWarning.FixMessage(); CommandLineInterpreter oCLI = new CommandLineInterpreter(); oCLI.Execute("SystemErrDialog"); return; }
/// <summary> /// Creates a new style Python exception from the .NET exception /// </summary> private static BaseException /*!*/ ToPythonNewStyle(System.Exception /*!*/ clrException) { // EndOfStreamException is not part of the OSError hierarchy if (clrException is Win32Exception || clrException is IOException && clrException is not EndOfStreamException) { int errorCode = clrException.HResult; if ((errorCode & ~0xfff) == unchecked ((int)0x80070000)) { errorCode = _OSError.WinErrorToErrno(errorCode & 0xfff); } // TODO: can we get filename and such? return(CreatePythonThrowable(OSError, errorCode, clrException.Message)); } BaseException pyExcep; if (clrException is InvalidCastException || clrException is ArgumentNullException) { // explicit extra conversions outside the generated hierarchy pyExcep = new BaseException(TypeError); } else { // conversions from generated code (in the generated hierarchy)... pyExcep = ToPythonHelper(clrException); } pyExcep.InitializeFromClr(clrException); return(pyExcep); }
public void ErroSql(string queryString, ArrayList paramsList, BaseException exe) { string @params = "["; int contador = 0; if ((paramsList == null)) { @params = ""; } else { while (contador < paramsList.Count) { if ((paramsList[contador] == null)) { @params = @params + "null"; } else { @params = @params + paramsList[contador].ToString(); } if ((contador != paramsList.Count - 1)) { @params = @params + ", "; } contador = contador + 1; } @params = @params + "]"; } Erro("Erro ao executar query: " + queryString + " " + @params, exe); }
void OnTurnCheck(object sender, object args) { BaseException exc = args as BaseException; if (exc.toggle == false) { return; } Unit target = sender as Unit; switch (step) { case 0: EquipCursedItem(target); break; case 1: Add <SlowStatusEffect>(target, 15); break; case 2: Add <StopStatusEffect>(target, 15); break; case 3: Add <HasteStatusEffect>(target, 15); break; default: UnEquipCursedItem(target); break; } step++; }
public void Function() { BaseException bexAssert = new BaseException("Assert", MessageLevel.Assert); bexAssert.FixMessage(); BaseException bexError = new BaseException("Error", MessageLevel.Error); bexError.FixMessage(); BaseException bexFatalError = new BaseException("FatalError", MessageLevel.FatalError); bexFatalError.FixMessage(); BaseException bexMessage = new BaseException("Message", MessageLevel.Message); bexMessage.FixMessage(); BaseException bexTrace = new BaseException("Trace", MessageLevel.Trace); bexTrace.FixMessage(); BaseException bexWarning = new BaseException("Warning", MessageLevel.Warning); bexWarning.FixMessage(); CommandLineInterpreter oCLI = new CommandLineInterpreter(); oCLI.Execute("SystemErrDialog"); return; }
private void ErrorIsSet() { var error = new Error("id"); var ex = new BaseException(error); Assert.Same(error, ex.Error); }
public void PostAlert(string name, Specie specie, Role role) { try { var data = new SkywalkerAlert() { Timestamp = DateTime.Now, Name = name, Specie = specie, Role = role, ClientIP = HttpContext.Current.Request.UserHostName + " (" + HttpContext.Current.Request.UserHostAddress + ")", BrowserInfo = HttpContext.Current.Request.UserAgent }; var client = new HttpClient(); client.BaseAddress = new Uri(ConfigurationManager.AppSettings["DeathstarServoceBaseUrl"]); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var response = client.PostAsJsonAsync(API_POST_SKYWALKERALERT, data).Result; if (!response.IsSuccessStatusCode) { throw new Exception("Couldn't connect with the Deathstar service!"); } } catch (Exception ex) { BaseException.HandleException(ex); } }
public bool CanMove(bool hasUnitMoved) { BaseException exc = new BaseException(true); this.PostNotification(CanMoveCheck, exc); return(exc.toggle); }
public bool CanPerform() { BaseException exc = new BaseException(true); this.PostNotification(CanPerformCheck, exc); return(exc.toggle); }
public void BaseException_with_message() { var e = new BaseException(_message); Assert.AreEqual(_message, e.Message); Assert.IsNull(e.InnerException); }
internal static IActionResult ErrorResult <TModel>(BaseException exception) { switch (exception) { case ForbiddenException _: case NotFoundException _: case UnauthorizedException _: LogWarning <TModel>("A warning has occurred.", exception); break; default: LogError <TModel>("An error has occurred.", exception); break; } var @try = HandleException <TModel>(exception); return(@try.Match( failure => failure switch { InvalidRequestException _ => new BadRequestObjectResult(@try), ForbiddenException _ => new ObjectResult(@try) { StatusCode = 403 }, NotFoundException _ => new NotFoundObjectResult(@try), AlreadyExistsException _ => new ConflictObjectResult(@try), UnauthorizedException _ => new UnauthorizedObjectResult(@try), InvalidObjectException _ => new UnprocessableEntityObjectResult(@try), _ => new ObjectResult(@try) { StatusCode = 500 }, },
public static void LogException(BaseException ex, string className, string methodName) { if (ex.InsertedLog) { return; } ex.InsertedLog = true; string curentUsername = Security.BUser.CurrentUser.UserName; if (curentUsername.ToLower().Equals("nunituser")) { return; } if (IsBusinessErrorLogEnable) { if (ex is InvalidPersianDateException) { businessErrorlogger.Error(curentUsername, className, methodName, "GTS.Clock.Business", " InvalidPersianDateException --> " + ((InvalidPersianDateException)ex).GetLogMessage(), ex); } else if (ex is UIBaseException) { businessErrorlogger.Error(curentUsername, className, methodName, "GTS.Clock.Business", String.Format("{0} --> {1}", ex.GetType().Name, ((UIBaseException)ex).GetLogMessage()), ex); } else { businessErrorlogger.Error(curentUsername, className, methodName, "GTS.Clock.Business", String.Format("{0} --> {1}", ex.GetType().Name, ((BaseException)ex).GetLogMessage()), ex); } } }
/// <summary> /// BaseException 日志 /// </summary> /// <param name="ex"></param> public static void BaseExceptionLog(BaseException ex) { if (!Config.IsDebug) { return; } using (var traceItem = new SenparcTraceItem(_logEndActon, "BaseException")) { traceItem.Log(ex.GetType().Name); traceItem.Log("Message:{0}", ex.Message); traceItem.Log("StackTrace:{0}", ex.StackTrace); if (ex.InnerException != null) { traceItem.Log("InnerException:{0}", ex.InnerException.Message); traceItem.Log("InnerException.StackTrace:{0}", ex.InnerException.StackTrace); } if (OnBaseExceptionFunc != null) { try { OnBaseExceptionFunc(ex); } catch { } } } }
bool CanTakeTurn(Unit target) { BaseException exc = new BaseException(GetCounter(target) >= turnActivation); target.PostNotification(TurnCheckNotification, exc); return(exc.toggle); }
public bool IsEqual(StepTemplate stepTemplate, out BaseException exception) { if (stepTemplate.InputDefinitions.Count() != InputDefinitions.Count()) { exception = new ConflictingStepTemplateException("Found existing template with conflicting inputs, the number of inputs is different."); return(false); } if (stepTemplate.AllowDynamicInputs != AllowDynamicInputs) { exception = new ConflictingStepTemplateException("Found existing template with conflicting settings, Allow dynamics input is different."); return(false); } if ((stepTemplate.OutputDefinitions == null && OutputDefinitions != null) || (stepTemplate.OutputDefinitions != null && OutputDefinitions == null) || (stepTemplate.OutputDefinitions.Count() != OutputDefinitions.Count())) { exception = new ConflictingStepTemplateException("Found existing template with conflicting inputs, the number of inputs is different."); return(false); } foreach (var input in stepTemplate.InputDefinitions) { var foundInputs = InputDefinitions.Where(i => i.Key == input.Key); if (foundInputs.Count() == 0) { exception = new ConflictingStepTemplateException("Missing input " + input.Key + " in existing template."); return(false); } if (foundInputs.First().Value.Type != input.Value.Type) { exception = new ConflictingStepTemplateException("Non matching type for input " + input.Key + "."); return(false); } } foreach (var output in stepTemplate.OutputDefinitions) { var foundOutputs = OutputDefinitions.Where(i => i.Key == output.Key); if (foundOutputs.Count() == 0) { exception = new ConflictingStepTemplateException("Missing output " + output.Key + " in existing template."); return(false); } if (foundOutputs.First().Value.Type != output.Value.Type) { exception = new ConflictingStepTemplateException("Non matching type for output " + output.Key + "."); return(false); } } exception = null; return(true); }
public static string ExceptionMessageStringToLogger(BaseException e, string messaje = null) { if (string.IsNullOrEmpty(messaje)) { messaje = e.Message; } return($"{e.ErrorCode}-{messaje}"); }
private static BaseException buildException(Object originatingObject, int statusCode) { String reason = HttpStatus.getReason(statusCode); BaseException answer = new BaseException(originatingObject, reason); answer.FaultCode = statusCode; return answer; }
/// <summary>This method will take a given exception and log it</summary> /// <param name="ex">The current exception</param> /// <example> /// try /// { /// throw new Exception(); /// } /// catch (Exception ex) /// { /// ExceptionHandler.Instance.HandleException(ex); /// } /// </example> public static void HandleException(BaseException ex) { if (Logger != null) { // log all exceptions at Error for initial implementation Logger.Log(LogLevel.Error, ex.AdditionalDataForLogging(), ex); } }
private void ErrorAndMessageAreSet() { var error = new Error("id"); var ex = new BaseException(error, message: "aMessage"); Assert.Same(error, ex.Error); Assert.Equal("aMessage", ex.Message); }
public void raiseError() { log.enteredMethod(); BaseException e = new BaseException(this, "TestService.raiseError() called"); e.ErrorDomain = "jsonbroker.TestService.RAISE_ERROR"; throw e; }
public static void AddData(this BaseException ex) { if (ex.CustomCode > 0 && !string.IsNullOrWhiteSpace(ex.CustomMessage)) { ex.Data.Add("custom_code", ex.CustomCode); ex.Data.Add("custom_message", ex.Message); } }
public static BaseException methodNotFound(Object originator, BrokerMessage request) { String methodName = request.getMethodName(); BaseException answer = new BaseException(originator, "Unknown methodName; methodName = '{0}'", methodName); answer.ErrorDomain = "jsonbroker.ServiceHelper.METHOD_NOT_FOUND"; answer.FaultCode = METHOD_NOT_FOUND; return answer; }
public static MediaType buildFromString(String value) { int indexOfSlash = value.IndexOf("/"); if (-1 == indexOfSlash) { BaseException e = new BaseException(typeof(MediaType), "-1 == indexOfSlash; value = {0}", value); throw e; } MediaType answer = new MediaType(value); String type = value.Substring(0, indexOfSlash); // int startIndex, int length log.debug(type, "type"); answer._type = type; String remainder = value.Substring(indexOfSlash+1); log.debug(remainder, "remainder"); String subtype; { int indexOfSemiColon = remainder.IndexOf(";"); if (-1 == indexOfSemiColon) { subtype = remainder.Trim(); } else { subtype = remainder.Substring(0, indexOfSemiColon); // int startIndex, int length ParametersScanner scanner = new ParametersScanner(indexOfSemiColon, remainder); String attribute; while (null != (attribute = scanner.NextAttribute())) { log.debug(attribute, "attribute"); String attributeValue = scanner.nextValue(); log.debug(attributeValue, "attributeValue"); answer._parameters[attribute] = attributeValue; } } } log.debug(subtype, "subtype"); answer._subtype = subtype; return answer; }
private DescribedService getService(String serviceName) { if (_services.ContainsKey(serviceName)) { return _services[serviceName]; } if (null == _next) { String technicalError = String.Format("null == answer, serviceName = '{0}'", serviceName); BaseException e = new BaseException(this, technicalError); e.ErrorDomain = ErrorDomain.SERVICE_NOT_FOUND; throw e; } return _next.getService(serviceName); }
public ServiceHttpProxy getOpenHttpProxy() { if (null == _host) { BaseException e = new BaseException(this, "null == _host"); throw e; } if (null != _openHttpProxy) { return _openHttpProxy; } NetworkAddress networkAddress = new NetworkAddress(_host, _port); HttpDispatcher httpDispatcher = new HttpDispatcher(networkAddress); _openHttpProxy = new ServiceHttpProxy(httpDispatcher); return _openHttpProxy; }
public static JsonObject ToJsonObject(BaseException baseException) { JsonObject answer = new JsonObject(); answer.put("errorDomain", baseException.ErrorDomain); // null is ok answer.put("faultCode", baseException.FaultCode); answer.put("faultMessage", baseException.Message); answer.put("underlyingFaultMessage", baseException.UnderlyingFaultMessage); answer.put("originator", baseException.getOriginator()); JsonArray jsonStackTrace; { jsonStackTrace = new JsonArray(); String[] stackTrace = ExceptionHelper.getStackTrace(baseException, true); for (int i = 0, count = stackTrace.Length; i < count; i++) { jsonStackTrace.Add(stackTrace[i]); } stackTrace = ExceptionHelper.getStackTrace(baseException, false); for (int i = 0, count = stackTrace.Length; i < count; i++) { jsonStackTrace.Add(stackTrace[i]); } } answer.put("stackTrace", jsonStackTrace); JsonObject faultContext = new JsonObject(); answer.put("faultContext", faultContext); return answer; }
public static ContentDisposition buildFromString(String value) { // see http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1 for rules ParametersScanner scanner = new ParametersScanner(0, value); String firstAttribute = scanner.NextAttribute(); if (null == firstAttribute) { BaseException e = new BaseException(typeof(ContentDisposition), "null == firstAttribute; value = {0}", value); throw e; } String dispExtensionToken = null; if ("attachment".Equals(firstAttribute)) { // we leave _dispExtensionToken as null } else { dispExtensionToken = firstAttribute; } ContentDisposition answer = new ContentDisposition(value); answer._dispExtensionToken = dispExtensionToken; for( String attribute = scanner.NextAttribute(); null != attribute; attribute = scanner.NextAttribute() ) { log.debug(attribute, "attribute"); String attributeValue = scanner.nextValue(); log.debug(attributeValue, "attributeValue"); answer._dispositionParameters[attribute] = attributeValue; } return answer; }
/// <summary> /// Creates a new style Python exception from the .NET exception /// </summary> private static BaseException/*!*/ ToPythonNewStyle(System.Exception/*!*/ clrException) { BaseException pyExcep; if (clrException is InvalidCastException || clrException is ArgumentNullException) { // explicit extra conversions outside the generated hierarchy pyExcep = new BaseException(TypeError); } else { // conversions from generated code (in the generated hierarchy)... pyExcep = ToPythonHelper(clrException); } pyExcep.InitializeFromClr(clrException); return pyExcep; }
public override void throwBaseAsBase_async(AMD_TestIntf_throwBaseAsBase cb, Ice.Current current) { BaseException be = new BaseException(); be.sbe = "sbe"; be.pb = new B(); be.pb.sb = "sb"; be.pb.pb = be.pb; cb.ice_exception(be); }
public void Start() { // Create a new server socket, set up all the endpoints, bind the socket and then listen { /* * * _serverSocket = new Socket(0, SocketType.Stream, ProtocolType.Tcp); * * call to "new Socket(0, SocketType.Stream, ProtocolType.Tcp)" * results in an error "The system detected an invalid pointer address in attempting to use a pointer argument in a call [ConnectionListener:start 47cd01]" * * for more information see "WSAEFAULT" at MS "Windows Sockets Error Codes" page (http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668%28v=vs.85%29.aspx) * * 47cd01 == ConnectionListener.SOCKET_BIND_FAILED * * ticket-reference: 95428884-3192-46D7-B9CD-87DA71BEEEAC * * */ _serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); } // vvv getting "Only one usage of each socket address" (jsonbroker:74F167C8-A8B9-4CB3-9D5D-E2D8B55E97ED) { _serverSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); log.info("ReuseAddress set to `true`"); } // ^^^ getting "Only one usage of each socket address" (jsonbroker:74F167C8-A8B9-4CB3-9D5D-E2D8B55E97ED) IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, _port); try { _serverSocket.Bind(endpoint); } catch (SocketException se) { BaseException be = new BaseException(this, se); be.FaultCode = SOCKET_BIND_FAILED; throw be; } _serverSocket.Blocking = true; _serverSocket.Listen(-1); log.debug(_port, "port"); Thread thread = new Thread(new ThreadStart(this.run)); thread.Name = "WebServer:" + _port; thread.IsBackground = true; thread.Start(); }
private static void BaseExceptionError(string error) { Eplan.EplApi.Base.BaseException bexMessage = new BaseException(error, MessageLevel.Error); bexMessage.FixMessage(); }
public String nextValue() { if (!moveToStartOfNextToken(true)) { BaseException e = new BaseException( this, "!moveToStartOfNextToken(true); _value = '{0}'", _value ); throw e; } bool isQuotedString = false; int startOfToken = _offset; // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6 if ('"' == _value[_offset]) { isQuotedString = true; _offset++; // move past the quotes startOfToken = _offset; if (_offset >= _value.Length) { BaseException e = new BaseException(this, "_offset >= _value.Length; _offset = {0}; _value.Length = {1}; _value = '{2}'", _offset, _value.Length, _value); throw e; } moveToEndOfQuotedString(); } else { moveToEndOfToken(); } int length = _offset - startOfToken; String answer = _value.Substring(startOfToken, length); // Subtring( int start, int length ) if (isQuotedString) // move past the closing quotes { _offset++; } return answer; }
public void BaseException_with_message() { var e = new BaseException(_message); Assert.AreEqual(_message, e.Message); Assert.IsNull(e.InnerException); }
private bool CanTakeAction(string actionNotification) { BaseException exc = new BaseException(true); this.PostNotification(actionNotification, exc); return exc.toggle; }
/// <summary> /// Creates a new style Python exception from the .NET exception /// </summary> private static BaseException/*!*/ ToPythonNewStyle(System.Exception/*!*/ clrException) { BaseException pyExcep; if (clrException is InvalidCastException || clrException is ArgumentNullException) { // explicit extra conversions outside the generated hierarchy pyExcep = new BaseException(TypeError); #if !SILVERLIGHT } else if (clrException is Win32Exception) { Win32Exception win32 = (Win32Exception)clrException; pyExcep = new _WindowsError(); if ((win32.ErrorCode & 0x80070000) == 0x80070000) { pyExcep.__init__(win32.ErrorCode & 0xffff, win32.Message); } else { pyExcep.__init__(win32.ErrorCode, win32.Message); } return pyExcep; #endif } else { // conversions from generated code (in the generated hierarchy)... pyExcep = ToPythonHelper(clrException); } pyExcep.InitializeFromClr(clrException); return pyExcep; }
public ServiceHttpProxy getAuthHttpProxy(ClientSecurityConfiguration clientSecurityConfiguration) { if (null == _host) { BaseException e = new BaseException(this, "null == _host"); throw e; } if (null != _authHttpProxy && _authHttpProxy.Authenticator.getSecurityConfiguration() == clientSecurityConfiguration) { return _authHttpProxy; } NetworkAddress networkAddress = new NetworkAddress(_host, _port); HttpDispatcher httpDispatcher = new HttpDispatcher(networkAddress); Authenticator authenticator = new Authenticator(false, clientSecurityConfiguration); _authHttpProxy = new ServiceHttpProxy(httpDispatcher, authenticator); return _authHttpProxy; }
public void post(HttpRequestAdapter requestAdapter, HttpResponseHandler responseAdapter) { HttpWebRequest request = buildPostRequest(requestAdapter, null); int statusCode = dispatch(request, null, responseAdapter); if (statusCode < 200 || statusCode > 299) { BaseException e = new BaseException(this, HttpStatus.getReason(statusCode)); e.FaultCode = statusCode; String requestUri = requestAdapter.RequestUri; e.addContext("requestUri", requestUri); throw e; } }
//////////////////////////////////////////////////////////////////////////// public void get(HttpRequestAdapter requestAdapter, Authenticator authenticator, HttpResponseHandler responseAdapter) { HttpWebRequest request = buildGetRequest(requestAdapter, authenticator); int statusCode = dispatch(request, authenticator, responseAdapter); if (401 == statusCode) { request = buildGetRequest(requestAdapter, authenticator); statusCode = dispatch(request, authenticator, responseAdapter); } if (statusCode < 200 || statusCode > 299) { BaseException e = new BaseException(this, HttpStatus.getReason(statusCode)); e.FaultCode = statusCode; String requestUri = requestAdapter.RequestUri; e.addContext("requestUri", requestUri); throw e; } }
public static BaseException toBaseException(JsonObject jsonObject) { String originator = jsonObject.GetString("originator", "NULL"); String fault_string = jsonObject.GetString("faultMessage", "NULL"); BaseException answer = new BaseException(originator, fault_string); { String errorDomain = jsonObject.GetString("errorDomain", null); answer.ErrorDomain = errorDomain; } int faultCode = jsonObject.GetInt("faultCode", BaseException.DEFAULT_FAULT_CODE); answer.FaultCode = faultCode; String underlyingFaultMessage = jsonObject.GetString("underlyingFaultMessage", null); answer.UnderlyingFaultMessage = underlyingFaultMessage; JsonArray stack_trace = jsonObject.GetJsonArray("stackTrace", null); if (null != stack_trace) { for (int i = 0, count = stack_trace.Count(); i < count; i++) { String key = "cause[" + i + "]"; String value = stack_trace.GetString(i, "NULL"); answer.addContext(key, value); } } JsonObject fault_context = jsonObject.GetJsonObject("faultContext", null); if (null != fault_context) { foreach (KeyValuePair<string, object> kvp in fault_context) { Object value = kvp.Value; if (null != value && value is String) { String key = kvp.Key; answer.addContext(key, (String)value); } } } return answer; }
public override void throwBaseAsBase(Ice.Current current) { BaseException be = new BaseException(); be.sbe = "sbe"; be.pb = new B(); be.pb.sb = "sb"; be.pb.pb = be.pb; throw be; }
public override Task throwBaseAsBaseAsync(Ice.Current current) { var be = new BaseException(); be.sbe = "sbe"; be.pb = new B(); be.pb.sb = "sb"; be.pb.pb = be.pb; throw be; }
private void TryProcess(MultiPartHandler multiPartHandler, bool skipFirstCrNl) { DelimiterDetector detector = new DelimiterDetector(_boundary); if (skipFirstCrNl) { byte[] crnl = new byte[]{0x0d,0x0a}; // 0x0d = cr; 0x0a = nl detector.update(crnl, 0, 2); } DelimiterIndicator indicator = findFirstDelimiterIndicator(detector); if (null == indicator) { BaseException e = new BaseException(this, "null == indicator; expected delimiter at start of stream"); throw e; } if (!(indicator is DelimiterFound)) { log.error("unimplemented: support for `DelimiterIndicator` types that are not `DelimiterFound`"); throw new BaseException(this, "!(indicator is DelimiterFound); indicator.GetType().Name", indicator.GetType().Name); } DelimiterFound delimiterFound = (DelimiterFound)indicator; _currentOffset = delimiterFound.EndOfDelimiter; while (!delimiterFound.IsCloseDelimiter) { delimiterFound = ProcessPart(multiPartHandler, detector); } multiPartHandler.FoundCloseDelimiter(); while (0 != _contentRemaining) { FillBuffer(); } }
public void BaseException_with_message_and_inner_exception() { var e = new BaseException(_message, _innerException); Assert.AreEqual(_message, e.Message); Assert.AreSame(_innerException, e.InnerException); }
private void FillBuffer() { _currentOffset = 0; long amountToRead = _contentRemaining; if (amountToRead > _buffer.Length) { amountToRead = _buffer.Length; } int bytesRead = _content.Read(_buffer, 0, (int)amountToRead); if (0 == bytesRead && 0 != amountToRead) // `0 == bytesRead` marks the end of the stream { BaseException e = new BaseException(this, "0 == bytesRead && 0 != amountToRead; amountToRead = {0}; _contentRemaining = {1}", amountToRead, _contentRemaining); throw e; } _contentRemaining -= bytesRead; _bufferEnd = bytesRead; }
bool CanTakeTurn(Unit target) { BaseException exc = new BaseException (GetCounter (target) >= turnActivation); target.PostNotification (TurnCheckNotification, exc); return exc.toggle; }
private static void BaseExceptionMessage(string message) { Eplan.EplApi.Base.BaseException bexMessage = new BaseException(message, MessageLevel.Message); bexMessage.FixMessage(); }
internal static BaseException CreatePythonThrowable(PythonType type, params object[] args) { BaseException be; if (type.UnderlyingSystemType == typeof(BaseException)) { be = new BaseException(type); } else { be = (BaseException)Activator.CreateInstance(type.UnderlyingSystemType, type); } be.__init__(args); return be; }
public bool CanPerform() { BaseException ex = new BaseException (true); this.PostNotification (CanPerformCheck, ex); return ex.toggle; }