Commit b990670 1 parent 124d4cb commit b990670 Copy full SHA for b990670
File tree 1 file changed +8
-0
lines changed
api/restful/routers/artwork
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,13 @@ func GetArtwork(ctx *gin.Context) {
70
70
artwork , err := service .GetArtworkByID (ctx , objectID )
71
71
hasKey := ctx .GetBool ("auth" )
72
72
if err != nil {
73
+ if errors .Is (err , mongo .ErrNoDocuments ) {
74
+ ctx .JSON (http .StatusNotFound , & ArtworkResponse {
75
+ Status : http .StatusNotFound ,
76
+ Message : "Artwork not found" ,
77
+ })
78
+ return
79
+ }
73
80
ctx .JSON (http .StatusInternalServerError , & ArtworkResponse {
74
81
Status : http .StatusInternalServerError ,
75
82
Message : func () string {
@@ -79,6 +86,7 @@ func GetArtwork(ctx *gin.Context) {
79
86
return "Failed to get artwork"
80
87
}(),
81
88
})
89
+ return
82
90
}
83
91
if artwork == nil {
84
92
ctx .JSON (http .StatusNotFound , & ArtworkResponse {
You can’t perform that action at this time.
0 commit comments