Fatalf and FatalFileRead

This commit is contained in:
Gregory Wells
2026-03-24 17:51:59 -04:00
parent 8d0cd0fd1b
commit 5aa2ce47c7
3 changed files with 23 additions and 1 deletions

View File

@@ -6,12 +6,26 @@ import (
"astraltech.xyz/accountmanager/src/logging"
)
// Reads a file, if fails just returns an error
func ReadFile(path string) ([]byte, error) {
logging.Event(logging.ReadFile, "static/blank_profile.jpg")
data, err := os.ReadFile(path)
if err != nil {
logging.Infof("Could not read file at %s", path)
logging.Infof("Error code: %e", err)
return nil, err
}
logging.Infof("Successfully read file at %s", path)
return data, err
}
func ReadRequiredFile(path string) []byte {
logging.Event(logging.ReadFile, "static/blank_profile.jpg")
data, err := os.ReadFile(path)
if err != nil {
logging.Fatalf("Could not read file at %s", path)
return nil
}
logging.Infof("Successfully read file at %s", path)
return data
}

View File

@@ -313,7 +313,7 @@ func main() {
var err error = nil
blankPhotoData, err = ReadFile("static/blank_profile.jpg")
if err != nil {
log.Fatal("Could not load blank profile image")
logging.Fatal("Could not load blank profile image")
}
serverConfig, err = loadServerConfig("./data/config.json")
if err != nil {