mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-01 10:00:19 +08:00
feat: handle error in ApiFilter
This commit is contained in:
@ -131,6 +131,15 @@ func GetOwnerAndNameFromId(id string) (string, string) {
|
||||
return tokens[0], tokens[1]
|
||||
}
|
||||
|
||||
func GetOwnerAndNameFromIdWithError(id string) (string, string, error) {
|
||||
tokens := strings.Split(id, "/")
|
||||
if len(tokens) != 2 {
|
||||
return "", "", errors.New("GetOwnerAndNameFromId() error, wrong token count for ID: " + id)
|
||||
}
|
||||
|
||||
return tokens[0], tokens[1], nil
|
||||
}
|
||||
|
||||
func GetOwnerFromId(id string) string {
|
||||
tokens := strings.Split(id, "/")
|
||||
if len(tokens) != 2 {
|
||||
|
Reference in New Issue
Block a user