Add status code when panic-ing

This commit is contained in:
David Dworken 2024-02-18 23:22:51 -08:00
parent c7862b1522
commit dba1e9a5db
No known key found for this signature in database
2 changed files with 6 additions and 2 deletions

View File

@ -191,7 +191,7 @@ If you'd like to temporarily allow someone else to search your shell history, yo
![demo showing the web UI searching for git](https://raw.githubusercontent.com/ddworken/hishtory/master/backend/web/landing/www/img/webui.png)
Note that this uses [HTTP Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication), so the credentials are sent over your local network via HTTP!
Note that this uses [HTTP Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication), so the credentials are sent over your local network via HTTP.
</blockquote></details>

View File

@ -30,7 +30,7 @@ type webUiData struct {
func getTableRowsForDisplay(ctx context.Context, searchQuery string) ([][]string, error) {
results, err := lib.Search(ctx, hctx.GetDb(ctx), searchQuery, 100)
if err != nil {
panic(err)
return nil, err
}
return buildTableRows(ctx, results)
}
@ -39,6 +39,7 @@ func htmx_resultsTable(w http.ResponseWriter, r *http.Request) {
searchQuery := r.URL.Query().Get("q")
tableRows, err := getTableRowsForDisplay(r.Context(), searchQuery)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
panic(err)
}
w.Header().Add("Content-Type", "text/html")
@ -49,6 +50,7 @@ func htmx_resultsTable(w http.ResponseWriter, r *http.Request) {
ColumnNames: hctx.GetConf(r.Context()).DisplayedColumns,
})
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
panic(err)
}
}
@ -74,6 +76,7 @@ func webuiHandler(w http.ResponseWriter, r *http.Request) {
searchQuery := r.URL.Query().Get("q")
tableRows, err := getTableRowsForDisplay(r.Context(), searchQuery)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
panic(err)
}
w.Header().Add("Content-Type", "text/html")
@ -83,6 +86,7 @@ func webuiHandler(w http.ResponseWriter, r *http.Request) {
ColumnNames: hctx.GetConf(r.Context()).DisplayedColumns,
})
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
panic(err)
}
}