diff --git a/feed-to-muc.go b/feed-to-muc.go
index 2286046..337d35d 100644
--- a/feed-to-muc.go
+++ b/feed-to-muc.go
@@ -56,14 +56,14 @@ func main() {
if _, err := os.Stat(configPath); os.IsNotExist(err) {
err = os.MkdirAll(configPath, 0700)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't create config path: ", err)
}
}
} else { // Get the current user.
curUser, err := user.Current()
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't get current user: ", err)
return
}
// Get home directory.
@@ -79,7 +79,7 @@ func main() {
if _, err := os.Stat(configPath + "config.json"); os.IsNotExist(err) {
err = os.MkdirAll(configPath, 0700)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't create config path: ", err)
}
}
@@ -89,7 +89,7 @@ func main() {
// Check that config file is existing.
if _, err := os.Stat(configFile); os.IsNotExist(err) {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't find config file: ", err)
}
// Read configuration file into variable config.
@@ -98,13 +98,13 @@ func main() {
decoder := json.NewDecoder(file)
config := configuration{}
if err := decoder.Decode(&config); err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't decode config: ", err)
}
if _, err := os.Stat(configFile); os.IsNotExist(err) {
err = os.MkdirAll(configPath, 0700)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't create config path: ", err)
}
}
@@ -122,13 +122,13 @@ func main() {
// Connect to server.
client, err = options.NewClient()
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Can't connect to xmpp server: ", err)
}
// Join the MUC
_, err := client.JoinMUCNoHistory(config.Muc, config.MucNick)
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Can't join MUC: ", err)
}
// Starting goroutine to ping the server every 30 seconds.
@@ -152,7 +152,7 @@ func main() {
output, err := getArticles(config.Feeds[i], config.MaxArticles, config.NoExcerpt)
if err != nil {
// Exit if an error occurs checking the feeds.
- log.Fatal(err)
+ log.Fatal("Error: Can't check feeds for new articles: ", err)
}
if output != "" {
@@ -161,7 +161,7 @@ func main() {
if err != nil {
// ToDo: Save message for resend.
// Exit if message can not be sent.
- log.Fatal(err)
+ log.Fatal("Error: Can't send message to MUC: ", err)
}
}
}
@@ -179,7 +179,7 @@ func pingMUC(client *xmpp.Client, botJid string, muc string, mucNick string) {
id, err = client.RawInformation(botJid, muc+"/"+mucNick, sid.Id(),
"get", "")
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Can't send MUC self ping: ", err)
}
pingSent = time.Now()
@@ -208,7 +208,7 @@ func pingServer(client *xmpp.Client, server string, botJid string) {
// Send ping to server to check if connection still exists.
err := client.PingC2S(botJid, strings.Split(server, ":")[0])
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Client2Server ping failed:", err)
}
}
}
@@ -217,7 +217,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
for { // Receive stanzas. ToDo: Receive stanzas continiously without 30s delay.
stanza, err := client.Recv()
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Failed receiving Stanzas:", err)
}
// Check stanzas, maybe we want to reply.
@@ -254,7 +254,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
"\"feeds\": List feeds I'm following.\n" +
"\"source\": Show source code URL."})
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Failed sending message to MUC:", err)
}
// Reply with repo address for `source`.
case "source":
@@ -263,7 +263,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
": My source can be found at " +
"https://salsa.debian.org/mdosch-guest/feed-to-muc"})
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Failed sending message to MUC:", err)
}
// Reply with the list of monitored feeds for `feeds`.
case "feeds":
@@ -277,7 +277,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
Type: "groupchat", Text: strings.Split(v.Remote, "/")[1] +
": Feeds I'm following:\n" + feedList})
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Failed sending message to MUC:", err)
}
}
@@ -301,13 +301,13 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
""+
"")
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Failed to reply to disco#info:", err)
}
} else if strings.Contains(string(v.Query), "") == true {
// Reply to pings.
_, err := client.RawInformation(client.JID(), v.From, v.ID, "result", "")
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Failed to reply to ping:", err)
}
} else {
// Send error replies for all other IQs.
@@ -315,7 +315,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str
"")
if err != nil {
- log.Fatal(err)
+ log.Fatal("Error: Failed to send error IQ:", err)
}
}
}
diff --git a/getarticles.go b/getarticles.go
index 1c4825b..4a52d31 100644
--- a/getarticles.go
+++ b/getarticles.go
@@ -38,14 +38,14 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
if _, err := os.Stat(cachePath); os.IsNotExist(err) {
err = os.MkdirAll(cachePath, 0700)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't create cache path:", err)
}
}
} else { // Get the current user.
curUser, err := user.Current()
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't get current user:", err)
return "", err
}
// Get home directory.
@@ -61,7 +61,7 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
if _, err := os.Stat(cachePath); os.IsNotExist(err) {
err = os.MkdirAll(cachePath, 0700)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't create cache path:", err)
}
}
@@ -74,7 +74,7 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
if _, err := os.Stat(cachePath); os.IsNotExist(err) {
err = os.MkdirAll(cachePath, 0700)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't create hash identifier for cache file:", err)
}
}
@@ -83,7 +83,7 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
if _, err := os.Stat(cacheFile); os.IsNotExist(err) {
file, err = os.Create(cacheFile)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't create cache file:", err)
}
defer file.Close()
@@ -94,26 +94,26 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
lastUpdateJSON, _ := json.MarshalIndent(lastUpdate, "", " ")
_, err = file.Write(lastUpdateJSON)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't write last update time stamp to cache file:", err)
}
} else {
file, err = os.OpenFile(cacheFile, os.O_RDWR, 0600)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't open cache file:", err)
}
defer file.Close()
decoder := json.NewDecoder(file)
lastUpdate := feedCache{}
if err := decoder.Decode(&lastUpdate); err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't decode laste updates time stamp:", err)
}
last, err = time.Parse(time.RFC3339, string(lastUpdate.LastChange))
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't parse last updates time stamp:", err)
}
}
@@ -179,19 +179,19 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) {
// ToDo: Replace timestamp without deleting.
err = os.Remove(cacheFile)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't delete cache file:", err)
}
file, err = os.Create(cacheFile)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't create cache file:", err)
}
defer file.Close()
lastUpdateJSON, _ := json.MarshalIndent(lastUpdate, "", " ")
_, err = file.Write(lastUpdateJSON)
if err != nil {
- log.Fatal("Error: ", err)
+ log.Fatal("Error: Can't write last update time stamp to cache file:", err)
}
// Remove redirects and tracking parameters from URL.