common errors as variable.

This commit is contained in:
Miroslav Šedivý
2021-08-29 17:09:13 +02:00
parent 530cc04805
commit 343b0c562a
17 changed files with 108 additions and 77 deletions

View File

@ -1,7 +1,6 @@
package capture
import (
"fmt"
"strings"
"sync"
@ -9,6 +8,7 @@ import (
"github.com/rs/zerolog/log"
"demodesk/neko/internal/capture/gst"
"demodesk/neko/internal/types"
)
type BroacastManagerCtx struct {
@ -67,7 +67,7 @@ func (manager *BroacastManagerCtx) Url() string {
func (manager *BroacastManagerCtx) createPipeline() error {
if manager.pipeline != nil {
return fmt.Errorf("pipeline already exists")
return types.ErrCapturePipelineAlreadyExists
}
var err error

View File

@ -1,7 +1,7 @@
package capture
import (
"fmt"
"errors"
"sync"
"sync/atomic"
"time"
@ -93,12 +93,12 @@ func (manager *ScreencastManagerCtx) Image() ([]byte, error) {
case sample := <-manager.sample:
return sample.Data, nil
case <-time.After(1 * time.Second):
return nil, fmt.Errorf("timeouted")
return nil, errors.New("timeouted")
}
}
if manager.image.Data == nil {
return nil, fmt.Errorf("image sample not found")
return nil, errors.New("image sample not found")
}
return manager.image.Data, nil
@ -109,7 +109,7 @@ func (manager *ScreencastManagerCtx) start() error {
defer manager.mu.Unlock()
if !manager.enabled {
return fmt.Errorf("screenshot pipeline not enabled")
return errors.New("screenshot pipeline not enabled")
}
err := manager.createPipeline()
@ -131,7 +131,7 @@ func (manager *ScreencastManagerCtx) stop() {
func (manager *ScreencastManagerCtx) createPipeline() error {
if manager.pipeline != nil {
return fmt.Errorf("pipeline already exists")
return types.ErrCapturePipelineAlreadyExists
}
var err error

View File

@ -1,7 +1,6 @@
package capture
import (
"fmt"
"reflect"
"sync"
@ -141,7 +140,7 @@ func (manager *StreamManagerCtx) Started() bool {
func (manager *StreamManagerCtx) createPipeline() error {
if manager.pipeline != nil {
return fmt.Errorf("pipeline already exists")
return types.ErrCapturePipelineAlreadyExists
}
var err error