mirror of
https://github.com/ViViDboarder/docset-sfdc.git
synced 2024-11-15 06:46:31 +00:00
0be33639b0
Large-ish refactor
37 lines
864 B
Go
37 lines
864 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"log"
|
|
)
|
|
|
|
// NewCustomError creates a custom error using a string as the message
|
|
func NewCustomError(message string) error {
|
|
return errors.New(message)
|
|
}
|
|
|
|
// NewFormatedError creates a new error using Sprintf
|
|
func NewFormatedError(format string, a ...interface{}) error {
|
|
return NewCustomError(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
// NewTypeNotFoundError returns an error for a TOCEntry with an unknown type
|
|
func NewTypeNotFoundError(entry TOCEntry) error {
|
|
return NewFormatedError("Type not found: %s %s", entry.Text, entry.ID)
|
|
}
|
|
|
|
// ExitIfError is a helper function for terminating if an error is not nil
|
|
func ExitIfError(err error) {
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// WarnIfError is a helper function for terminating if an error is not nil
|
|
func WarnIfError(err error) {
|
|
if err != nil {
|
|
LogDebug(err.Error())
|
|
}
|
|
}
|