瀏覽代碼

no index return 404

visuddhinanda 3 月之前
父節點
當前提交
150d83f895
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      api-v13/app/Http/Controllers/SearchPlusController.php

+ 5 - 1
api-v13/app/Http/Controllers/SearchPlusController.php

@@ -129,7 +129,11 @@ class SearchPlusController extends Controller
     public function show($id)
     {
         //
-        return $this->ok(HitItemDTO::fromArray($this->searchService->get($id)));
+        try {
+            return $this->ok(HitItemDTO::fromArray($this->searchService->get($id)));
+        } catch (\Throwable $th) {
+            return $this->error("no such index {$id}", 404, 404);
+        }
     }
 
     /**