package diag

import 

// Error represents an error with context that can be showed.
type Error struct {
	Type    string
	Message string
	Context Context
}

// Error returns a plain text representation of the error.
func ( *Error) () string {
	return fmt.Sprintf("%s: %d-%d in %s: %s",
		.Type, .Context.From, .Context.To, .Context.Name, .Message)
}

// Range returns the range of the error.
func ( *Error) () Ranging {
	return .Context.Range()
}

// Show shows the error.
func ( *Error) ( string) string {
	 := fmt.Sprintf("%s: \033[31;1m%s\033[m\n", .Type, .Message)
	return  + .Context.ShowCompact(+"  ")
}