Fatalf and FatalFileRead
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user