krystal/go-katapult

View on GitHub
errors_custom.go

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
package katapult

import (
    "fmt"
    "strings"
)

// This file contains custom Error() functions for select error types in
// errors_generated.go, allowing customized error messages based on the Detail
// fields available for each specific type.

func (s *ScopeNotGrantedError) Error() string {
    if s.Detail == nil || len(s.Detail.Scopes) == 0 {
        return s.CommonError.Error()
    }

    return fmt.Sprintf(
        "%s: required scopes: %s",
        s.CommonError.BaseError(), strings.Join(s.Detail.Scopes, ", "),
    )
}