improve: Propagate DataStream exceptions via ErrorChanged event
This commit is contained in:
1 parent
60af47c4eb
commit
2c1b7b95a4
4 files changed
+150
-57
No files matched your search
@@ -32,6 +32,9 @@ namespace BCG
|
||||
public DataStream (DataStream realSource)
|
||||
{
|
||||
myRealSource = realSource;
|
||||
if (myRealSource is not null) {
|
||||
myRealSource.ErrorChanged += OnError;
|
||||
}
|
||||
myOnChangeDelegate = null;
|
||||
myPendingAdds = new Stack();
|
||||
}
|
||||
@@ -48,6 +51,8 @@ namespace BCG
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<Exception> ErrorChanged;
|
||||
|
||||
public delegate void ChangeDelegate(object newValue);
|
||||
public event ChangeDelegate onChange
|
||||
{
|
||||
@@ -120,8 +125,15 @@ namespace BCG
|
||||
protected virtual object myGetValueForInitialSubscription()
|
||||
{return myLastValue;}
|
||||
|
||||
protected void mySetRealSource (DataStream src)
|
||||
{myRealSource = src;}
|
||||
protected void mySetRealSource (DataStream src) {
|
||||
if (myRealSource is not null) {
|
||||
myRealSource.ErrorChanged -= OnError;
|
||||
}
|
||||
myRealSource = src;
|
||||
if (myRealSource is not null) {
|
||||
myRealSource.ErrorChanged += OnError;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void myOnFirstSubscriber() {myFirstSubImplemented = false;}
|
||||
protected virtual void myOnLastSubscriber () {myLastSubImplemented = false;}
|
||||
@@ -143,6 +155,11 @@ namespace BCG
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnError(Exception error) {
|
||||
Log.Gen.error($"{GetType()} OnError: {error}");
|
||||
ErrorChanged?.Invoke(error);
|
||||
}
|
||||
|
||||
public Guid ID
|
||||
{
|
||||
get
|
||||
|
||||
Reference in new issue
Block a user