MCPcopy Index your code
hub / github.com/coder/coder / extractStatusCode

Function extractStatusCode

coderd/x/chatd/chaterror/signals.go:91–108  ·  view source on GitHub ↗
(lower string)

Source from the content-addressed store, hash-verified

89)
90
91func extractStatusCode(lower string) int {
92 if matches := statusCodePattern.FindStringSubmatch(lower); len(matches) == 2 {
93 if code, err := strconv.Atoi(matches[1]); err == nil {
94 return code
95 }
96 return 0
97 }
98 for _, loc := range standaloneStatusPattern.FindAllStringIndex(lower, -1) {
99 if shouldSkipStandaloneStatusMatch(lower, loc[0]) {
100 continue
101 }
102 if code, err := strconv.Atoi(lower[loc[0]:loc[1]]); err == nil {
103 return code
104 }
105 return 0
106 }
107 return 0
108}
109
110func shouldSkipStandaloneStatusMatch(lower string, start int) bool {
111 // Skip values in host:port text. A later standalone status code in the

Callers 2

ExtractStatusCodeForTestFunction · 0.85
ClassifyFunction · 0.85

Calls 1

Tested by 1

ExtractStatusCodeForTestFunction · 0.68