♻️ Refactor: Remove unused variable in handleError
The LSP I use now caught that I never used this variable
This commit is contained in:
parent
3461144e69
commit
d687608ba8
1 changed files with 11 additions and 11 deletions
22
editor.go
22
editor.go
|
@ -23,7 +23,7 @@ type Template struct {
|
||||||
func EditFile(w http.ResponseWriter, r *http.Request) {
|
func EditFile(w http.ResponseWriter, r *http.Request) {
|
||||||
userSession, err := validateSession(w, r)
|
userSession, err := validateSession(w, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handleError(w, "Error validating session", err)
|
handleError("Error validating session", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func EditFile(w http.ResponseWriter, r *http.Request) {
|
||||||
// Read file content
|
// Read file content
|
||||||
fileContent, err := readFileContent(filePath)
|
fileContent, err := readFileContent(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handleError(w, "Error reading file content", err)
|
handleError("Error reading file content", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ func EditFile(w http.ResponseWriter, r *http.Request) {
|
||||||
templatePath := filepath.Join(templateFilePath, templateName)
|
templatePath := filepath.Join(templateFilePath, templateName)
|
||||||
templateContent, err := readFileContent(templatePath)
|
templateContent, err := readFileContent(templatePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handleError(w, "Error reading template content", err)
|
handleError("Error reading template content", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// overwrites file content. Could also change this to append.
|
// overwrites file content. Could also change this to append.
|
||||||
|
@ -67,7 +67,7 @@ func EditFile(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
templates, err := getTemplateList()
|
templates, err := getTemplateList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handleError(w, "Error getting template list", err)
|
handleError("Error getting template list", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Update the Templates slice to assign the current filename
|
// 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) {
|
func SaveFile(w http.ResponseWriter, r *http.Request) {
|
||||||
userSession, err := validateSession(w, r)
|
userSession, err := validateSession(w, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handleError(w, "Error validating session", err)
|
handleError("Error validating session", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,19 +120,19 @@ func SaveFile(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
} else if !os.IsNotExist(err) {
|
} else if !os.IsNotExist(err) {
|
||||||
// Error accessing the file, handle the error or return an error response
|
// 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := updateFilename(userSession.username, filename, newFilename)
|
err := updateFilename(userSession.username, filename, newFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handleError(w, "Error updating filename", err)
|
handleError("Error updating filename", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.Rename(filePath, newFilePath) // Rename the file to the new filename
|
err = os.Rename(filePath, newFilePath) // Rename the file to the new filename
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handleError(w, "Error renaming file", err)
|
handleError("Error renaming file", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ func SaveFile(w http.ResponseWriter, r *http.Request) {
|
||||||
// Create or open the file
|
// Create or open the file
|
||||||
file, err := os.Create(newFilePath)
|
file, err := os.Create(newFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handleError(w, "Error creating file", err)
|
handleError("Error creating file", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
@ -154,7 +154,7 @@ func SaveFile(w http.ResponseWriter, r *http.Request) {
|
||||||
// Write the edited content to the file
|
// Write the edited content to the file
|
||||||
_, err = file.WriteString(editedContent)
|
_, err = file.WriteString(editedContent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handleError(w, "Error writing edited content to file", err)
|
handleError("Error writing edited content to file", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ func SaveFile(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Redirect(w, r, "/home", http.StatusSeeOther)
|
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)
|
log.Printf("%s: %v", errMsg, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue