Skip to content

Commit

Permalink
pingonerror command updates
Browse files Browse the repository at this point in the history
  • Loading branch information
double-fault committed Apr 11, 2017
1 parent be1349e commit 8a028ee
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Sources/SwiftChatSE/ErrorHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public var afterTooManyErrors: () -> () = { abort() }
public var errorsInLast30Seconds = 0

///A string that will be appended to the error message so that the bot's author can be pinged by errors..
public var ping = " (cc @NobodyNada)"
public var ping = " (cc @<enter owner name here>)"

///A bool variable which will control the usage of the ping ^ variable.
public var pingonerror = true

///Logs an error.
public func handleError(_ error: Error, _ context: String? = nil) {
Expand All @@ -62,8 +65,14 @@ public func handleError(_ error: Error, _ context: String? = nil) {
else {
contextStr = ""
}

let message1 = " An error (\(errorType)) occured\(contextStr)\(ping):"

let message1: String

if (pingonerror == true) {
message1 = " An error (\(errorType)) occured\(contextStr)\(ping):"
} else {
message1 = " An error (\(errorType)) occured\(contextStr):"
}

if let room = errorRoom {
room.postMessage(message1 + "\n " + errorDetails.replacingOccurrences(of: "\n", with: "\n "))
Expand Down

0 comments on commit 8a028ee

Please sign in to comment.