Skip to content

Commit 7388a82

Browse files
Merge pull request #45 from form3tech-oss/nl-return-interaction-not-found
feat: Add interaction not found error
2 parents 4b791c4 + 6f60945 commit 7388a82

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

internal/app/pactproxy/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (a *api) interactionsGetHandler(c echo.Context) error {
187187
alias := c.Param("alias")
188188
interaction, found := a.interactions.Load(alias)
189189
if !found {
190-
return c.JSON(http.StatusBadRequest, httpresponse.Errorf("interaction %q not found", alias))
190+
return c.JSON(http.StatusNotFound, httpresponse.Errorf("interaction %q not found", alias))
191191
}
192192

193193
return c.JSON(http.StatusOK, interaction)

internal/app/pactproxy/proxy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func TestInteractionsGetHandler(t *testing.T) {
135135
{
136136
name: "interaction not found",
137137
interactions: &Interactions{},
138-
code: http.StatusBadRequest,
138+
code: http.StatusNotFound,
139139
body: `{"error_message":"interaction \"test\" not found"}`,
140140
},
141141
} {

pkg/pactproxy/pactproxy.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
log "github.com/sirupsen/logrus"
1515
)
1616

17+
var InteractionNotFoundError = errors.New("interaction not found")
18+
1719
type PactProxy struct {
1820
client http.Client
1921
url string
@@ -144,6 +146,9 @@ func (p *PactProxy) ReadInteractionDetails(alias string) (*Interaction, error) {
144146
return nil, errors.Wrap(err, "http get")
145147
}
146148
if res.StatusCode != http.StatusOK {
149+
if res.StatusCode == http.StatusNotFound {
150+
return nil, InteractionNotFoundError
151+
}
147152
return nil, errors.New("fail")
148153
}
149154
interaction := &Interaction{}

0 commit comments

Comments
 (0)