Пример #1
0
/*
Prints the error message on os.Stdout, prefixed with the phrase: Runtime Error:
then exits the relish process with status 1 (meaning abnormal exit as opposed to status 0 which would mean an exit with success.)
*/
func Stop1(cfl CodeFileLocated, p Positioned, errorMessage interface{}) {

	errorMsgStr := fmt.Sprint("Runtime Error: ", errorMessage)
	file := cfl.CodeFile()
	if file == nil {
		Stop(errorMessage)
	}
	position := file.Position(p.Pos())
	errorMsgStr = dbg.FmtErr(position, errorMsgStr)
	fmt.Fprintln(os.Stdout, errorMsgStr)
	os.Exit(1)
}
Пример #2
0
/*
Prints the formatted error message on os.Stdout, prefixed with the phrase: Runtime Error:
Formats the message just like Printf except also adds a carriage return after the formatted message.
then exits the relish process with status 1 (meaning abnormal exit as opposed to status 0 which would mean an exit with success.)
*/
func Stopf1(cfl CodeFileLocated, p Positioned, errorMessage string, args ...interface{}) {
	file := cfl.CodeFile()
	if file == nil {
		Stopf(errorMessage, args...)
	}
	errorMessage = "Runtime Error: " + errorMessage
	errorMessage = fmt.Sprintf(errorMessage, args...)
	position := file.Position(p.Pos())
	errorMessage = dbg.FmtErr(position, errorMessage)
	fmt.Fprintln(os.Stdout, errorMessage)
	os.Exit(1)
}
Пример #3
0
func (e *Error) Error() string {
	return dbg.FmtErr(e.Pos, e.Msg)

	/*
	   	if e.Pos.Filename != "" || e.Pos.IsValid() {
	   		// don't print "<unknown position>"
	   		// TODO(gri) reconsider the semantics of Position.IsValid

	           fileNamePosString := e.Pos.String()
	           srcPos := strings.LastIndex(fileNamePosString, "/src/")
	           artifactDir := fileNamePosString[:srcPos+5]
	           packageFilePos := fileNamePosString[srcPos+5:]

	   		return "\n" + packageFilePos + ":\n\n" + e.Msg + "\n\nError in software artifact\n" + artifactDir + "\n"
	   	}
	   	return e.Msg
	*/
}