(err error, errorID string, log logrus.FieldLogger, q url.Values)
| 825 | } |
| 826 | |
| 827 | func getErrorQueryString(err error, errorID string, log logrus.FieldLogger, q url.Values) *url.Values { |
| 828 | switch e := err.(type) { |
| 829 | case *HTTPError: |
| 830 | if e.ErrorCode == apierrors.ErrorCodeSignupDisabled { |
| 831 | q.Set("error", "access_denied") |
| 832 | } else if e.ErrorCode == apierrors.ErrorCodeUserBanned { |
| 833 | q.Set("error", "access_denied") |
| 834 | } else if e.ErrorCode == apierrors.ErrorCodeProviderEmailNeedsVerification { |
| 835 | q.Set("error", "access_denied") |
| 836 | } else if str, ok := oauthErrorMap[e.HTTPStatus]; ok { |
| 837 | q.Set("error", str) |
| 838 | } else { |
| 839 | q.Set("error", "server_error") |
| 840 | } |
| 841 | if e.HTTPStatus >= http.StatusInternalServerError { |
| 842 | e.ErrorID = errorID |
| 843 | // this will get us the stack trace too |
| 844 | log.WithError(e.Cause()).Error(e.Error()) |
| 845 | } else { |
| 846 | log.WithError(e.Cause()).Info(e.Error()) |
| 847 | } |
| 848 | q.Set("error_description", e.Message) |
| 849 | q.Set("error_code", e.ErrorCode) |
| 850 | case *OAuthError: |
| 851 | q.Set("error", e.Err) |
| 852 | q.Set("error_description", e.Description) |
| 853 | log.WithError(e.Cause()).Info(e.Error()) |
| 854 | case ErrorCause: |
| 855 | return getErrorQueryString(e.Cause(), errorID, log, q) |
| 856 | default: |
| 857 | error_type, error_description := "server_error", err.Error() |
| 858 | |
| 859 | // Provide better error messages for certain user-triggered Postgres errors. |
| 860 | if pgErr := utilities.NewPostgresError(e); pgErr != nil { |
| 861 | error_description = pgErr.Message |
| 862 | if oauthErrorType, ok := oauthErrorMap[pgErr.HttpStatusCode]; ok { |
| 863 | error_type = oauthErrorType |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | q.Set("error", error_type) |
| 868 | q.Set("error_description", error_description) |
| 869 | } |
| 870 | return &q |
| 871 | } |
| 872 | |
| 873 | func (a *API) getExternalRedirectURL(r *http.Request) string { |
| 874 | ctx := r.Context() |
no test coverage detected
searching dependent graphs…