MCPcopy Create free account
hub / github.com/kataras/iris / getErrorText

Method getErrorText

middleware/accesslog/accesslog.go:1053–1076  ·  view source on GitHub ↗
(err error)

Source from the content-addressed store, hash-verified

1051var lineBreaksReplacer = strings.NewReplacer("\n\r", " ", "\n", " ")
1052
1053func (ac *AccessLog) getErrorText(err error) (text string) { // caller checks for nil.
1054 if errPanic, ok := context.IsErrPanicRecovery(err); ok {
1055 ac.Flush() // flush any buffered contents to be written to the output.
1056
1057 switch ac.PanicLog {
1058 case LogHandler:
1059 text = errPanic.CurrentHandlerFileLine
1060 case LogCallers:
1061 text = strings.Join(errPanic.Callers, "\n")
1062 case LogStack:
1063 text = string(errPanic.Stack)
1064 }
1065
1066 text = fmt.Sprintf("error(%v %s)", errPanic.Cause, text)
1067 } else {
1068 text = fmt.Sprintf("error(%s)", err.Error())
1069 }
1070
1071 if !ac.KeepMultiLineError {
1072 return lineBreaksReplacer.Replace(text)
1073 }
1074
1075 return text
1076}

Callers 1

afterMethod · 0.95

Calls 3

FlushMethod · 0.95
IsErrPanicRecoveryFunction · 0.92
ErrorMethod · 0.65

Tested by

no test coverage detected