github.com/primecitizens/pcz/std@v0.2.1/core/assert/throw_other.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 //go:build !(js && wasm) 5 6 package assert 7 8 import ( 9 "github.com/primecitizens/pcz/std/core/debug" 10 ) 11 12 // Throw triggers a fatal error that dumps a stack trace and exits. 13 // 14 //go:nosplit 15 func Throw(s ...string) { 16 switch len(s) { 17 case 0: 18 println("fatal", "error") 19 case 1: 20 println("fatal", "error:", s[0]) 21 default: 22 print("fatal", " ", "error:") 23 for _, s := range s { 24 print(" ", s) 25 } 26 println() 27 } 28 29 // TODO: print stacktrace 30 31 debug.Abort() 32 }