Преглед на файлове

Removed all fatal from desktop module

Toby Chui преди 2 години
родител
ревизия
9c91392b4b
променени са 1 файла, в които са добавени 7 реда и са изтрити 4 реда
  1. 7 4
      desktop.go

+ 7 - 4
desktop.go

@@ -47,6 +47,7 @@ func DesktopInit() {
 	//Initialize desktop database
 	err := sysdb.NewTable("desktop")
 	if err != nil {
+		log.Println("Unable to create database table for Desktop. Please validation your installation.")
 		log.Fatal(err)
 		os.Exit(1)
 	}
@@ -333,14 +334,14 @@ func setDesktopLocationFromPath(filename string, username string, x int, y int)
 	newLocation.Y = y
 
 	//Check if the file exits
-	if fshAbs.FileExists(path) == false {
+	if !fshAbs.FileExists(path) {
 		return errors.New("Given filename not exists.")
 	}
 
 	//Parse the location to json
 	jsonstring, err := json.Marshal(newLocation)
 	if err != nil {
-		log.Fatal("Unable to parse new file location on desktop for file: " + path)
+		log.Println("[Desktop] Unable to parse new file location on desktop for file: " + path)
 		return err
 	}
 
@@ -460,7 +461,7 @@ func desktop_theme_handler(w http.ResponseWriter, r *http.Request) {
 		//List all the currnet themes in the list
 		themes, err := filepath.Glob("web/img/desktop/bg/*")
 		if err != nil {
-			log.Fatal("Error. Unable to search bg from destkop image root. Are you sure the web data folder exists?")
+			log.Println("[Desktop] Unable to search bg from destkop image root. Are you sure the web data folder exists?")
 			return
 		}
 		//Prase the results to json array
@@ -499,7 +500,9 @@ func desktop_theme_handler(w http.ResponseWriter, r *http.Request) {
 		//Return the results as JSON string
 		jsonString, err := json.Marshal(desktopThemeList)
 		if err != nil {
-			log.Fatal(err)
+			log.Println("[Desktop] Marshal desktop wallpaper list error: " + err.Error())
+			common.SendJSONResponse(w, string("[]"))
+			return
 		}
 		common.SendJSONResponse(w, string(jsonString))
 		return