Exemplo n.º 1
0
func errorSummary(error *revel.Error) string {
	var message = fmt.Sprintf("%4sStatus: %s\n%4sIn %s", "", error.Description, "", error.Path)
	if error.Line != 0 {
		message += fmt.Sprintf(" (around line %d): ", error.Line)
		for _, line := range error.ContextSource() {
			if line.IsError {
				message += line.Source
			}
		}
	}
	return message
}
Exemplo n.º 2
0
// errorSummary gets an error and returns its summary in human readable format.
func errorSummary(err *revel.Error) (message string) {
	message = fmt.Sprintf("%4sStatus: %s\n%4sIn %s", "", err.Description, "", err.Path)

	// If line of error isn't known return the message as is.
	if err.Line == 0 {
		return
	}

	// Otherwise, include info about the line number and the relevant
	// source code lines.
	message += fmt.Sprintf(" (around line %d): ", err.Line)
	for _, line := range err.ContextSource() {
		if line.IsError {
			message += line.Source
		}
	}

	return
}