aboutsummaryrefslogtreecommitdiffhomepage
path: root/builder/error.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-07-21 14:12:55 +0200
committerRon Evans <[email protected]>2024-07-21 18:23:49 +0200
commit04d1261f8a48b18a4404c52f858c35c0668316cd (patch)
tree850babc5c14ae4fb20f1e9d9ff67dd20958d9688 /builder/error.go
parent3e2230eadb14d0e54db621976d60d654487f891a (diff)
downloadtinygo-04d1261f8a48b18a4404c52f858c35c0668316cd.tar.gz
tinygo-04d1261f8a48b18a4404c52f858c35c0668316cd.zip
build: add package ID to compiler and optimization error messages
This improves error reporting slightly.
Diffstat (limited to 'builder/error.go')
-rw-r--r--builder/error.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/builder/error.go b/builder/error.go
index 0f920a031..3531007fb 100644
--- a/builder/error.go
+++ b/builder/error.go
@@ -3,7 +3,8 @@ package builder
// MultiError is a list of multiple errors (actually: diagnostics) returned
// during LLVM IR generation.
type MultiError struct {
- Errs []error
+ ImportPath string
+ Errs []error
}
func (e *MultiError) Error() string {
@@ -15,14 +16,15 @@ func (e *MultiError) Error() string {
// newMultiError returns a *MultiError if there is more than one error, or
// returns that error directly when there is only one. Passing an empty slice
// will lead to a panic.
-func newMultiError(errs []error) error {
+// The importPath may be passed if this error is for a single package.
+func newMultiError(errs []error, importPath string) error {
switch len(errs) {
case 0:
panic("attempted to create empty MultiError")
case 1:
return errs[0]
default:
- return &MultiError{errs}
+ return &MultiError{importPath, errs}
}
}