internal/pipewire: generic Core::Error handling
All checks were successful
Test / Create distribution (push) Successful in 58s
Test / Hakurei (push) Successful in 8m1s
Test / Hakurei (race detector) (push) Successful in 10m19s
Test / Sandbox (push) Successful in 1m30s
Test / Sandbox (race detector) (push) Successful in 2m18s
Test / Hpkg (push) Successful in 3m21s
Test / Flake checks (push) Successful in 1m31s
All checks were successful
Test / Create distribution (push) Successful in 58s
Test / Hakurei (push) Successful in 8m1s
Test / Hakurei (race detector) (push) Successful in 10m19s
Test / Sandbox (push) Successful in 1m30s
Test / Sandbox (race detector) (push) Successful in 2m18s
Test / Hpkg (push) Successful in 3m21s
Test / Flake checks (push) Successful in 1m31s
This flushes message buffer before queueing the event expecting the error. Since this is quite useful and relatively complex, it is relocated to a method of Context. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -642,33 +642,28 @@ func (registry *Registry) destroy(id Int) error {
|
||||
}
|
||||
|
||||
// Destroy tries to destroy the global object with id.
|
||||
func (registry *Registry) Destroy(id Int) error {
|
||||
if err := registry.destroy(id); err != nil {
|
||||
func (registry *Registry) Destroy(id Int) (err error) {
|
||||
asCoreError := registry.ctx.expectsCoreError(registry.ID, &err)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = registry.destroy(id); err != nil {
|
||||
return err
|
||||
}
|
||||
destroySeq := registry.ctx.currentSeq()
|
||||
|
||||
err := registry.ctx.GetCore().Sync()
|
||||
if err == nil {
|
||||
if err = registry.ctx.GetCore().Sync(); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var coreError *CoreError
|
||||
if proxyErrors, ok := err.(ProxyConsumeError); !ok ||
|
||||
len(proxyErrors) != 1 ||
|
||||
!errors.As(proxyErrors[0], &coreError) ||
|
||||
coreError == nil ||
|
||||
coreError.ID != registry.ID ||
|
||||
coreError.Sequence != destroySeq {
|
||||
return err
|
||||
}
|
||||
if coreError := asCoreError(); coreError == nil {
|
||||
return
|
||||
} else {
|
||||
switch syscall.Errno(-coreError.Result) {
|
||||
case syscall.EPERM:
|
||||
return &PermissionError{registry.ID, coreError.Message}
|
||||
|
||||
switch syscall.Errno(-coreError.Result) {
|
||||
case syscall.EPERM:
|
||||
return &PermissionError{registry.ID, coreError.Message}
|
||||
|
||||
default:
|
||||
return coreError
|
||||
default:
|
||||
return coreError
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user