protected virtual void notifyListeners() { D.assert(_debugAssertNotDisposed()); if (_listeners != null) { var localListeners = new List <VoidCallback>(_listeners); foreach (VoidCallback listener in localListeners) { try { if (_listeners.Contains(listener)) { listener(); } } catch (Exception ex) { IEnumerable <DiagnosticsNode> infoCollector() { yield return(new DiagnosticsProperty <ChangeNotifier>( $"The {GetType()} sending notification was", this, style: DiagnosticsTreeStyle.errorProperty )); } UIWidgetsError.reportError(new UIWidgetsErrorDetails( exception: ex, library: "foundation library", context: new ErrorDescription($"while dispatching notifications for {GetType()}"), informationCollector: infoCollector )); } } } }
protected virtual void notifyListeners() { D.assert(this._debugAssertNotDisposed()); if (this._listeners != null) { var localListeners = new List <VoidCallback>(this._listeners); foreach (VoidCallback listener in localListeners) { try { if (this._listeners.Contains(listener)) { listener(); } } catch (Exception ex) { UIWidgetsError.reportError(new UIWidgetsErrorDetails( exception: ex, library: "foundation library", context: "while dispatching notifications for " + this.GetType(), informationCollector: information => { information.AppendLine("The " + this.GetType() + " sending notification was:"); information.Append(" " + this); } )); } } } }
public override string ToString() { var buffer = new StringBuilder(); if (this.library.isNotEmpty() || this.context.isNotEmpty()) { if (this.library.isNotEmpty()) { buffer.AppendFormat("Error caught by {0}", this.library); if (this.context.isNotEmpty()) { buffer.Append(", "); } } else { buffer.Append("Exception "); } if (this.context.isNotEmpty()) { buffer.AppendFormat("thrown {0}", this.context); } buffer.Append(". "); } else { buffer.Append("An error was caught. "); } buffer.AppendLine(this.exceptionAsString()); if (this.informationCollector != null) { this.informationCollector(buffer); } if (this.exception.StackTrace != null) { IEnumerable <string> stackLines = this.exception.StackTrace.TrimEnd().Split('\n'); if (this.stackFilter != null) { stackLines = this.stackFilter(stackLines); } else { stackLines = UIWidgetsError.defaultStackFilter(stackLines); } buffer.Append(string.Join("\n", stackLines.ToArray())); } return(buffer.ToString().TrimEnd()); }