From 3580f6234f65d551889f798639f5c2f0f751863e Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Tue, 26 Mar 2019 00:23:55 -0700 Subject: [PATCH] Return typed error when no candidate pairs Returning a typed error allows us to handle it gracefully in pions/webrtc --- agent.go | 2 +- errors.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/agent.go b/agent.go index efc4b34..6f5b167 100644 --- a/agent.go +++ b/agent.go @@ -796,7 +796,7 @@ func (a *Agent) getBestPair() (*candidatePair, error) { out := <-res if out == nil { - return nil, errors.New("no Valid Candidate Pairs Available") + return nil, ErrNoCandidatePairs } return out, nil diff --git a/errors.go b/errors.go index 57446d4..e0771de 100644 --- a/errors.go +++ b/errors.go @@ -26,4 +26,7 @@ var ( // ErrClosed indicates the agent is closed ErrClosed = errors.New("the agent is closed") + + // ErrNoCandidatePairs indicates agent does not have a valid candidate pair + ErrNoCandidatePairs = errors.New("no candidate pairs available") )