mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 15:27:27 +00:00
Add warning log
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
|
)
|
||||||
|
|
||||||
|
func HandleError(err error, messages ...string) {
|
||||||
|
PrintErrorAndExit(1, err, messages...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func PrintErrorAndExit(exitCode int, err error, messages ...string) {
|
||||||
|
printError(err)
|
||||||
|
|
||||||
|
if len(messages) > 0 {
|
||||||
|
for _, message := range messages {
|
||||||
|
fmt.Println(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Exit(exitCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func PrintWarning(message string) {
|
||||||
|
color.Yellow("Warning: %v", message)
|
||||||
|
}
|
||||||
|
|
||||||
|
func PrintMessageAndExit(messages ...string) {
|
||||||
|
if len(messages) > 0 {
|
||||||
|
for _, message := range messages {
|
||||||
|
fmt.Println(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func printError(e error) {
|
||||||
|
color.Red("Hmm, we ran into an error: %v", e)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user