github.com/goplus/llgo@v0.8.3/internal/runtime/error.go (about)

     1  package runtime
     2  
     3  type errorString string
     4  
     5  func (e errorString) RuntimeError() {}
     6  
     7  func (e errorString) Error() string {
     8  	return "runtime error: " + string(e)
     9  }
    10  
    11  func AssertRuntimeError(b bool, msg string) {
    12  	if b {
    13  		panic(errorString(msg).Error())
    14  	}
    15  }
    16  
    17  func AssertNegativeShift(b bool) {
    18  	if b {
    19  		panic(errorString("negative shift amount").Error())
    20  	}
    21  }
    22  
    23  func AssertIndexRange(b bool) {
    24  	if b {
    25  		panic(errorString("index out of range").Error())
    26  	}
    27  }