github.com/haraldrudell/parl@v0.4.176/go-error-source.go (about)

     1  /*
     2  © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package parl
     7  
     8  import "strconv"
     9  
    10  type GoErrorContext uint8
    11  
    12  const none = "NONE"
    13  
    14  var goErrorMap = map[GoErrorContext]string{
    15  	GeNonFatal:    "GeNonFatal",
    16  	GePreDoneExit: "GePreDoneExit",
    17  	GeLocalChan:   "GeLocalChan",
    18  	GeTerminate:   "GeTerminate",
    19  	GeExit:        "GeExit",
    20  }
    21  
    22  func (ge GoErrorContext) String() (s string) {
    23  	var ok bool
    24  	if s, ok = goErrorMap[ge]; !ok {
    25  		s = none + strconv.Itoa(int(ge))
    26  	}
    27  
    28  	return
    29  }