2018-11-09 13:54:47 +00:00
|
|
|
|
|
|
|
|
2018-11-11 16:44:30 +00:00
|
|
|
package common
|
2018-11-09 13:54:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
import "os"
|
|
|
|
import "regexp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func AbortError (_error error, _message string) () {
|
|
|
|
LogError (_error, _message)
|
|
|
|
log.Printf ("[!!] [89251d36] aborting!\n")
|
|
|
|
os.Exit (1)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func LogError (_error error, _message string) () {
|
|
|
|
|
|
|
|
if _message != "#" {
|
|
|
|
if (_message == "") && (_error != nil) {
|
|
|
|
_message = "[70d7e7c6] unexpected error encountered!";
|
|
|
|
}
|
|
|
|
if _message != "" {
|
|
|
|
log.Printf ("[ee] %s\n", _message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if _error != nil {
|
|
|
|
_errorString := _error.Error ()
|
|
|
|
if logErrorMessageProper.MatchString (_errorString) {
|
|
|
|
log.Printf ("[ee] %s\n", _errorString)
|
|
|
|
} else {
|
2022-09-11 17:38:42 +00:00
|
|
|
log.Printf ("[ee] [c776ae31] || %T || %q\n", _error, _errorString)
|
|
|
|
log.Printf ("[ee] [ddd6baae] || %T || %#v\n", _error, _error)
|
2018-11-09 13:54:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-15 17:11:34 +00:00
|
|
|
var logErrorMessageProper = regexp.MustCompile (`\A\[[0-9a-f]{8}\] [^\n]+\z`)
|
2018-11-09 13:54:47 +00:00
|
|
|
|