ceremonyclient/bedlam/compiler/errors.go
Cassandra Heart dbd95bd9e9
v2.1.0 (#439)
* v2.1.0 [omit consensus and adjacent] - this commit will be amended with the full release after the file copy is complete

* 2.1.0 main node rollup
2025-09-30 02:48:15 -05:00

44 lines
842 B
Go

package compiler
import (
"fmt"
"source.quilibrium.com/quilibrium/monorepo/bedlam/compiler/utils"
)
type CompileError struct {
Stage CompileStage // "parse", "compile", "circuit"
SourcePos string
Location *utils.Point
Err error // origin error
}
type CompileStage int
const (
CompileStageParse CompileStage = iota
CompileStageCompile
CompileStageCircuit
)
var stateName = map[CompileStage]string{
CompileStageParse: "parse",
CompileStageCompile: "compile",
CompileStageCircuit: "circuit",
}
func (cs CompileStage) String() string {
return stateName[cs]
}
func (e *CompileError) Error() string {
msg := fmt.Sprintf("Compile error [%s]: %v", e.Stage, e.Err)
if e.Location != nil {
msg += fmt.Sprintf(", %s", e.Location)
}
if e.SourcePos != "" {
msg += fmt.Sprintf("\n%s", e.SourcePos)
}
return msg
}