...

Source file src/github.com/goph/emperror/panic.go

Documentation: github.com/goph/emperror

     1  package emperror
     2  
     3  // Panic panics if the passed error is not nil.
     4  // If the error does not contain any stack trace, the function attaches one, starting from the frame of the
     5  // "Panic" function call.
     6  //
     7  // This function is useful with HandleRecover when panic is used as a flow control tool to stop the application.
     8  func Panic(err error) {
     9  	if err != nil {
    10  		if _, ok := StackTrace(err); !ok {
    11  			err = &wrappedError{
    12  				err:   err,
    13  				stack: callers(),
    14  			}
    15  		}
    16  
    17  		panic(err)
    18  	}
    19  }
    20  

View as plain text