diff --git a/README.md b/README.md index 2bba81c..ce6c956 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ The endpoint returns a [search result](#search-result-object) JSON object -If no results are found the endpoint returns a http status code of `404` +If no results are found the endpoint returns a http status code of `204 No Content` ### Text Object diff --git a/main/src/main/java/com/github/topi314/lavasearch/SearchManager.java b/main/src/main/java/com/github/topi314/lavasearch/SearchManager.java index b28b50b..abaf0d1 100644 --- a/main/src/main/java/com/github/topi314/lavasearch/SearchManager.java +++ b/main/src/main/java/com/github/topi314/lavasearch/SearchManager.java @@ -41,7 +41,10 @@ public void shutdown() { } @Nullable - public AudioSearchResult loadSearch(String query, Set types) { + public AudioSearchResult loadSearch(String query, Set types) throws IllegalStateException { + if (this.searchManagers.isEmpty()){ + throw new IllegalStateException("No search source registered"); + } for (var sourceManager : this.searchManagers) { var searchResults = sourceManager.loadSearch(query, types); if (searchResults != null) { diff --git a/plugin/src/main/java/com/github/topi314/lavasearch/plugin/AudioSearchRestHandler.kt b/plugin/src/main/java/com/github/topi314/lavasearch/plugin/AudioSearchRestHandler.kt index 5b4f960..7e8ad88 100644 --- a/plugin/src/main/java/com/github/topi314/lavasearch/plugin/AudioSearchRestHandler.kt +++ b/plugin/src/main/java/com/github/topi314/lavasearch/plugin/AudioSearchRestHandler.kt @@ -36,6 +36,6 @@ class AudioSearchRestHandler( val result = searchManager.loadSearch(query, finalTypes) return if (result != null) { ResponseEntity.ok(result.toSearchResult(playerManager, pluginInfoModifiers, searchResultInfoModifiers)) - } else ResponseEntity.notFound().build() + } else ResponseEntity.noContent().build() } }