/// <summary> /// Handles a .NET Exception that occurred during the interpretation of Synery code. /// </summary> /// <param name="exception">The thrown .NET Exception</param> /// <param name="context">The interpretation context that caused the Exception (e.g. used to print the line number).</param> /// <returns> /// false = Exception hasn't been handled, so please re-throw it. /// true = Exception handled. No further action is required. Continue interpretation. /// </returns> private bool HandleException(Exception exception, Antlr4.Runtime.ParserRuleContext context) { INestedScope nestedScope = Memory.Scopes.OfType <INestedScope>().FirstOrDefault(); if (nestedScope != null && nestedScope.IsTerminated == true && !(context is SyneryParser.ThrowStatementContext) && !(exception is InterfaceBoosterException)) { // The current block has already been terminated. // Therefore don't throw or create any new exceptions return(true); } else { if (context is SyneryParser.ObserveBlockContext) { // We're now in an OBSERVE-block. // Try to find a handle block that catches the exception. ExecutionExceptionRecord executionException = new ExecutionExceptionRecord(); executionException.Message = exception.Message; executionException.Line = context.Start.Line; executionException.CharPosition = context.Start.Column; this.HandleSyneryEvent(context, executionException.GetAsSyneryValue()); return(true); } if (exception is SyneryInterpretationException) { // The exception already is an interpretation exception. // Continue re-throwing it. return(false); } /* * It seems that the exception is not an interpretation exception. * Create a new exception and enrich it with the parser-context and a * new message that contains all messages from the nested exceptions. */ string message = string.Format("An unexpected error occurred while interpreting '{1}' on line {2}: {0}{3}", Environment.NewLine, context.GetText(), context.Start.Line, ExceptionHelper.GetNestedExceptionMessages(exception)); throw new SyneryInterpretationException(context, message, exception); } }
/// <summary> /// Get a dictionary with all the system record types provided by Interface Booster. /// </summary> /// <returns></returns> public static IDictionary <SyneryType, IRecordType> GetSystemRecordTypes() { IDictionary <SyneryType, IRecordType> listOfRecordTypes = new Dictionary <SyneryType, IRecordType>(); // get the signatures of the default system record types listOfRecordTypes.Add(GetRecordTypeSignature(EventRecord.GetRecordType())); listOfRecordTypes.Add(GetRecordTypeSignature(ExceptionRecord.GetRecordType())); listOfRecordTypes.Add(GetRecordTypeSignature(ExecutionExceptionRecord.GetRecordType())); listOfRecordTypes.Add(GetRecordTypeSignature(LibraryPluginExceptionRecord.GetRecordType())); listOfRecordTypes.Add(GetRecordTypeSignature(ProviderPluginConnectionExceptionRecord.GetRecordType())); listOfRecordTypes.Add(GetRecordTypeSignature(ProviderPluginDataExchangeExceptionRecord.GetRecordType())); return(listOfRecordTypes); }