diff options
author | Runxi Yu <me@runxiyu.org> | 2025-02-13 19:05:22 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-02-13 19:05:22 +0800 |
commit | d7889bf3eab55f56d2ca94c462ca130fde705871 (patch) | |
tree | aeecbbc43bb8608ef2299fa167da4d00bf53f98d /http_handle_repo_tree.go | |
parent | schema.sql: password TEXT should not be NOT NULL (diff) | |
download | forge-d7889bf3eab55f56d2ca94c462ca130fde705871.tar.gz forge-d7889bf3eab55f56d2ca94c462ca130fde705871.tar.zst forge-d7889bf3eab55f56d2ca94c462ca130fde705871.zip |
http_handle_*.go: Fix http.Error calls
Previously when I was converting the fmt.Fprintln calls into http.Error,
there was a mistake in my sed command which caused some of the messages
to have double colons. This should fix them.
Diffstat (limited to 'http_handle_repo_tree.go')
-rw-r--r-- | http_handle_repo_tree.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/http_handle_repo_tree.go b/http_handle_repo_tree.go index cd88a6f..69bc40f 100644 --- a/http_handle_repo_tree.go +++ b/http_handle_repo_tree.go @@ -22,31 +22,31 @@ func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string] if errors.Is(err, err_no_ref_spec) { ref_type = "head" } else { - http.Error(w, "Error querying ref type:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error querying ref type: "+err.Error(), http.StatusInternalServerError) return } } params["ref_type"], params["ref"], params["path_spec"] = ref_type, ref_name, path_spec repo, description, err := open_git_repo(r.Context(), group_name, repo_name) if err != nil { - http.Error(w, "Error opening repo:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error opening repo: "+err.Error(), http.StatusInternalServerError) return } params["repo_description"] = description ref_hash, err := get_ref_hash_from_type_and_name(repo, ref_type, ref_name) if err != nil { - http.Error(w, "Error getting ref hash:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error getting ref hash: "+err.Error(), http.StatusInternalServerError) return } commit_object, err := repo.CommitObject(ref_hash) if err != nil { - http.Error(w, "Error getting commit object:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error getting commit object: "+err.Error(), http.StatusInternalServerError) return } tree, err := commit_object.Tree() if err != nil { - http.Error(w, "Error getting file tree:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error getting file tree: "+err.Error(), http.StatusInternalServerError) return } @@ -58,7 +58,7 @@ func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string] if err != nil { file, err := tree.File(path_spec) if err != nil { - http.Error(w, "Error retrieving path:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error retrieving path: "+err.Error(), http.StatusInternalServerError) return } if len(raw_path_spec) != 0 && raw_path_spec[len(raw_path_spec)-1] == '/' { @@ -67,7 +67,7 @@ func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string] } file_contents, err := file.Contents() if err != nil { - http.Error(w, "Error reading file:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error reading file: "+err.Error(), http.StatusInternalServerError) return } lexer := chroma_lexers.Match(path_spec) @@ -76,7 +76,7 @@ func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string] } iterator, err := lexer.Tokenise(nil, file_contents) if err != nil { - http.Error(w, "Error tokenizing code:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error tokenizing code: "+err.Error(), http.StatusInternalServerError) return } var formatted_unencapsulated bytes.Buffer @@ -84,7 +84,7 @@ func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string] formatter := chroma_formatters_html.New(chroma_formatters_html.WithClasses(true), chroma_formatters_html.TabWidth(8)) err = formatter.Format(&formatted_unencapsulated, style, iterator) if err != nil { - http.Error(w, "Error formatting code:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error formatting code: "+err.Error(), http.StatusInternalServerError) return } formatted_encapsulated := template.HTML(formatted_unencapsulated.Bytes()) @@ -92,7 +92,7 @@ func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string] err = templates.ExecuteTemplate(w, "repo_tree_file", params) if err != nil { - http.Error(w, "Error rendering template:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error rendering template: "+err.Error(), http.StatusInternalServerError) return } return @@ -109,7 +109,7 @@ func handle_repo_tree(w http.ResponseWriter, r *http.Request, params map[string] err = templates.ExecuteTemplate(w, "repo_tree_dir", params) if err != nil { - http.Error(w, "Error rendering template:: "+err.Error(), http.StatusInternalServerError) + http.Error(w, "Error rendering template: "+err.Error(), http.StatusInternalServerError) return } } |