Upatede Error type to SourceError

Added processor object to code
Verified compile errors appearing
Signed-off-by: notzippy@gmail.com
This commit is contained in:
notzippy@gmail.com
2020-04-25 15:32:29 -07:00
parent 9a9511d28f
commit 548cbc1764
10 changed files with 282 additions and 99 deletions

View File

@@ -8,7 +8,7 @@ import (
// The error is a wrapper for the
type (
Error struct {
SourceError struct {
SourceType string // The type of source that failed to build.
Title, Path, Description string // Description of the error, as presented to the user.
Line, Column int // Where the error was encountered.
@@ -24,8 +24,8 @@ type (
}
)
// Return a new error object
func NewError(source, title,path,description string) *Error {
return &Error {
func NewError(source, title,path,description string) *SourceError {
return &SourceError{
SourceType:source,
Title:title,
Path:path,
@@ -34,7 +34,7 @@ func NewError(source, title,path,description string) *Error {
}
// Creates a link based on the configuration setting "errors.link"
func (e *Error) SetLink(errorLink string) {
func (e *SourceError) SetLink(errorLink string) {
errorLink = strings.Replace(errorLink, "{{Path}}", e.Path, -1)
errorLink = strings.Replace(errorLink, "{{Line}}", strconv.Itoa(e.Line), -1)
@@ -44,7 +44,7 @@ func (e *Error) SetLink(errorLink string) {
// Error method constructs a plaintext version of the error, taking
// account that fields are optionally set. Returns e.g. Compilation Error
// (in views/header.html:51): expected right delim in end; got "}"
func (e *Error) Error() string {
func (e *SourceError) Error() string {
if e == nil {
panic("opps")
}
@@ -69,7 +69,7 @@ func (e *Error) Error() string {
// ContextSource method returns a snippet of the source around
// where the error occurred.
func (e *Error) ContextSource() []SourceLine {
func (e *SourceError) ContextSource() []SourceLine {
if e.SourceLines == nil {
return nil
}