Live video on the AT Protocol
1package globalerror 2 3import ( 4 "fmt" 5 "path/filepath" 6 "runtime" 7 "sync" 8) 9 10var GlobalErrors []error 11var mut sync.Mutex 12 13func GlobalError(err error) { 14 if GlobalErrors == nil { 15 return 16 } 17 _, file, line, _ := runtime.Caller(1) 18 19 go func() { 20 mut.Lock() 21 defer mut.Unlock() 22 _, myfile, _, _ := runtime.Caller(0) 23 // This assumes that the root directory of streamplace is two levels above this folder. 24 // If that changes, please update this rootDir resolution. 25 rootDir := filepath.Join(filepath.Dir(myfile), "..", "..") 26 rel, _ := filepath.Rel(rootDir, file) 27 GlobalErrors = append(GlobalErrors, fmt.Errorf("%s:%d: %w", rel, line, err)) 28 }() 29}