@@ -648,13 +648,14 @@ func (api *API) previousTemplateVersionByOrganizationAndName(rw http.ResponseWri
648
648
OrganizationID : organization .ID ,
649
649
Name : templateVersionName ,
650
650
})
651
- if errors .Is (err , sql .ErrNoRows ) {
652
- httpapi .Write (ctx , rw , http .StatusNotFound , codersdk.Response {
653
- Message : fmt .Sprintf ("No template version found by name %q." , templateVersionName ),
654
- })
655
- return
656
- }
657
651
if err != nil {
652
+ if errors .Is (err , sql .ErrNoRows ) {
653
+ httpapi .Write (ctx , rw , http .StatusNotFound , codersdk.Response {
654
+ Message : fmt .Sprintf ("No template version found by name %q." , templateVersionName ),
655
+ })
656
+ return
657
+ }
658
+
658
659
httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
659
660
Message : "Internal error fetching template version." ,
660
661
Detail : err .Error (),
@@ -667,13 +668,15 @@ func (api *API) previousTemplateVersionByOrganizationAndName(rw http.ResponseWri
667
668
Name : templateVersionName ,
668
669
TemplateID : templateVersion .TemplateID ,
669
670
})
670
- if errors .Is (err , sql .ErrNoRows ) {
671
- httpapi .Write (ctx , rw , http .StatusNotFound , codersdk.Response {
672
- Message : fmt .Sprintf ("No previous template version found for %q." , templateVersionName ),
673
- })
674
- return
675
- }
671
+
676
672
if err != nil {
673
+ if errors .Is (err , sql .ErrNoRows ) {
674
+ httpapi .Write (ctx , rw , http .StatusNotFound , codersdk.Response {
675
+ Message : fmt .Sprintf ("No previous template version found for %q." , templateVersionName ),
676
+ })
677
+ return
678
+ }
679
+
677
680
httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
678
681
Message : "Internal error fetching the previous template version." ,
679
682
Detail : err .Error (),
0 commit comments