Skip to content

Commit

Permalink
fix checker
Browse files Browse the repository at this point in the history
  • Loading branch information
mallvielfrass committed Jul 10, 2021
1 parent 8e5aefa commit 062c590
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
22 changes: 17 additions & 5 deletions Errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,35 @@ func errorHandlePrepare(e error, a ...interface{}) string {
//if e != nil {
path, line, fn := WhoCallerErr()
if a != nil {

return fmt.Sprintf(Sprint("#rbtError #RRR[#gbt%s#RRR:#gbt%s #ybt%s()#RRR]: \n\tDescription: #RRR[#ybt %s#RRR] \n\t#RRRMessage: #ybt%s"), path, line, fn, fmt.Sprintf("%v", a[0]), e.Error())

}
return fmt.Sprintf(Sprint("#rbtError#RRR[#gbt%s#RRR:#gbt%s #ybt%s()#RRR]: \n\t#RRRMessage: #ybt%s"), e.Error())
return fmt.Sprintf(Sprint("#rbtError#RRR[#gbt%s#RRR:#gbt%s #ybt%s()#RRR]: \n\t#RRRMessage: #ybt%s"), path, line, fn, e.Error())
//}
//return ""
}
func ErrorHandle(e error, a ...interface{}) {
if e != nil {
fmt.Println(errorHandlePrepare(e, a[0]))
var msg string
if a != nil {
msg = errorHandlePrepare(e, a[0])
} else {
// fmt.Println("else")
msg = errorHandlePrepare(e)
}
fmt.Println(msg)

}

}
func ErrorHandleFatal(e error, a ...interface{}) {
if e != nil {
std.Output(2, errorHandlePrepare(e, a[0]))
var msg string
if a != nil {
msg = errorHandlePrepare(e, a[0])
} else {
msg = errorHandlePrepare(e)
}
std.Output(2, msg)
os.Exit(1)
}
}
14 changes: 10 additions & 4 deletions cmd/ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"errors"
"os"

"github.com/mallvielfrass/fmc"
)
Expand Down Expand Up @@ -32,7 +33,7 @@ func beta() {
fmc.ErrorHandle(errors.New("Err"), "file")
}
func betaR() {
fmc.ErrorHandleFatal(errors.New("Err"), "file")
fmc.ErrorHandleFatal(errors.New("Err"))
}
func main() {
// fmc.Printf("#yst I#ybt love#bbt Go#gbt!\n")
Expand Down Expand Up @@ -75,8 +76,13 @@ func main() {
// panic(err)
// }
// fmc.PrintStruct(config)
beta()
fmc.ErrorHandle(errors.New("Err"), "file")
betaR()
// beta()
// fmc.ErrorHandle(errors.New("Err"), "file")
fmc.ErrorHandle(errors.New("Err"))
// betaR()
//fmc.ErrorHandleFatal(errors.New("Err"))
token := os.Getenv("token")
if token == "" {
fmc.ErrorHandleFatal(errors.New("os variable 'token' not found"))
}
}

0 comments on commit 062c590

Please sign in to comment.