♻️ Refactor: Remove unused variable in handleError

The LSP I use now caught that I never used this variable
This commit is contained in:
James Musselman 2024-06-26 10:03:24 -05:00
parent 3461144e69
commit d687608ba8
Signed by: Musselman
GPG key ID: 1DAEFF35ECB5D6DB

View file

@ -23,7 +23,7 @@ type Template struct {
func EditFile(w http.ResponseWriter, r *http.Request) {
userSession, err := validateSession(w, r)
if err != nil {
handleError(w, "Error validating session", err)
handleError("Error validating session", err)
return
}
@ -35,7 +35,7 @@ func EditFile(w http.ResponseWriter, r *http.Request) {
// Read file content
fileContent, err := readFileContent(filePath)
if err != nil {
handleError(w, "Error reading file content", err)
handleError("Error reading file content", err)
return
}
@ -44,7 +44,7 @@ func EditFile(w http.ResponseWriter, r *http.Request) {
templatePath := filepath.Join(templateFilePath, templateName)
templateContent, err := readFileContent(templatePath)
if err != nil {
handleError(w, "Error reading template content", err)
handleError("Error reading template content", err)
return
}
// overwrites file content. Could also change this to append.
@ -67,7 +67,7 @@ func EditFile(w http.ResponseWriter, r *http.Request) {
templates, err := getTemplateList()
if err != nil {
handleError(w, "Error getting template list", err)
handleError("Error getting template list", err)
return
}
// Update the Templates slice to assign the current filename
@ -90,7 +90,7 @@ func EditFile(w http.ResponseWriter, r *http.Request) {
func SaveFile(w http.ResponseWriter, r *http.Request) {
userSession, err := validateSession(w, r)
if err != nil {
handleError(w, "Error validating session", err)
handleError("Error validating session", err)
return
}
@ -120,19 +120,19 @@ func SaveFile(w http.ResponseWriter, r *http.Request) {
}
} else if !os.IsNotExist(err) {
// Error accessing the file, handle the error or return an error response
handleError(w, "Error: Unable to access file", err)
handleError("Error: Unable to access file", err)
return
}
err := updateFilename(userSession.username, filename, newFilename)
if err != nil {
handleError(w, "Error updating filename", err)
handleError("Error updating filename", err)
return
}
err = os.Rename(filePath, newFilePath) // Rename the file to the new filename
if err != nil {
handleError(w, "Error renaming file", err)
handleError("Error renaming file", err)
return
}
}
@ -140,7 +140,7 @@ func SaveFile(w http.ResponseWriter, r *http.Request) {
// Create or open the file
file, err := os.Create(newFilePath)
if err != nil {
handleError(w, "Error creating file", err)
handleError("Error creating file", err)
return
}
defer file.Close()
@ -154,7 +154,7 @@ func SaveFile(w http.ResponseWriter, r *http.Request) {
// Write the edited content to the file
_, err = file.WriteString(editedContent)
if err != nil {
handleError(w, "Error writing edited content to file", err)
handleError("Error writing edited content to file", err)
return
}
@ -164,7 +164,7 @@ func SaveFile(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/home", http.StatusSeeOther)
}
func handleError(w http.ResponseWriter, errMsg string, err error) {
func handleError(errMsg string, err error) {
log.Printf("%s: %v", errMsg, err)
}