MCPcopy Create free account
hub / github.com/larksuite/cli / ExitCodeForCategory

Function ExitCodeForCategory

internal/output/exitcode.go:29–47  ·  view source on GitHub ↗

ExitCodeForCategory maps an errs.Category to the shell exit code. Multiple categories may share an exit code (Authentication / Authorization / Config all map to 3), so the relationship is many-to-one.

(cat errs.Category)

Source from the content-addressed store, hash-verified

27// Multiple categories may share an exit code (Authentication / Authorization /
28// Config all map to 3), so the relationship is many-to-one.
29func ExitCodeForCategory(cat errs.Category) int {
30 switch cat {
31 case errs.CategoryValidation:
32 return ExitValidation
33 case errs.CategoryAuthentication, errs.CategoryAuthorization, errs.CategoryConfig:
34 return ExitAuth
35 case errs.CategoryNetwork:
36 return ExitNetwork
37 case errs.CategoryAPI:
38 return ExitAPI
39 case errs.CategoryPolicy:
40 return ExitContentSafety
41 case errs.CategoryInternal:
42 return ExitInternal
43 case errs.CategoryConfirmation:
44 return ExitConfirmationRequired
45 }
46 return ExitInternal
47}
48
49// ExitCodeOf returns the shell exit code for any error.
50// - typed errors (*errs.PermissionError, *errs.APIError, *errs.ConfigError,

Callers 3

ExitCodeOfFunction · 0.85
TestExitCodeForCategoryFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestExitCodeForCategoryFunction · 0.68