feat: surface runtime errors in engine status
Record the most recent runtime error (capture, encode, packet, audio) in the engine and expose it via Status.Err. The GUI shows it in the status label (highlighted as a danger) and in the tray tooltip, so a denied screen-share or encoder failure is visible without reading logs.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package flinger
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -77,6 +78,34 @@ func TestNewRejectsBadSource(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestSetErrStatus verifies runtime errors are exposed via Status and can be
|
||||
// cleared.
|
||||
func TestSetErrStatus(t *testing.T) {
|
||||
cfg := DefaultConfig()
|
||||
cfg.Source = "pattern"
|
||||
cfg.Port = 19757
|
||||
|
||||
eng, err := New(cfg)
|
||||
if err != nil {
|
||||
t.Fatalf("New: %v", err)
|
||||
}
|
||||
|
||||
if st := eng.Status(); st.Err != nil {
|
||||
t.Fatalf("expected no error initially, got %v", st.Err)
|
||||
}
|
||||
|
||||
sentinel := errors.New("test capture failure")
|
||||
eng.setErr(sentinel)
|
||||
if st := eng.Status(); st.Err != sentinel {
|
||||
t.Errorf("expected sentinel error, got %v", st.Err)
|
||||
}
|
||||
|
||||
eng.setErr(nil)
|
||||
if st := eng.Status(); st.Err != nil {
|
||||
t.Errorf("expected cleared error, got %v", st.Err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestValidate rejects out-of-range values.
|
||||
func TestValidate(t *testing.T) {
|
||||
bad := []func(*Config){
|
||||
|
||||
Reference in New Issue
Block a user