// DetectError wraps the provided error with additional information
// useful for applications.
DetectError wraps the provided error with additional information
useful for applications.
// DetectError wraps the provided error with additional information // useful for applications .
func DetectError(err error) error {
	switch {
	case errors.Is(err, sql.ErrNoRows):
		return ErrNotFound
	case errors.Is(err, http.ErrNoCookie):
		return NewError(err, http.StatusBadRequest, "session cookie is invalid")
	case errors.Is(err, sessionup.ErrUnauthorized):
		return NewError(err, http.StatusUnauthorized,
			strings.ToLower(http.StatusText(http.StatusUnauthorized)))
	}
	if serr, ok := err.(*statusError); ok {
		if serr.code < 500 {
			return err
		}
	}
	return NewError(err, http.StatusInternalServerError,
		strings.ToLower(http.StatusText(http.StatusInternalServerError)))
}
func DetectError ( err error ) error { switch { case errors . Is ( err , sql . ErrNoRows ) : return ErrNotFound case errors . Is ( err , http . ErrNoCookie ) : return NewError ( err , http . StatusBadRequest , " " ) case errors . Is ( err , sessionup . ErrUnauthorized ) : return NewError ( err , http . StatusUnauthorized , strings . ToLower ( http . StatusText ( http . StatusUnauthorized ) ) ) } if serr , ok := err . ( * statusError ) ; ok { if serr . code < 500 { return err } } return NewError ( err , http . StatusInternalServerError , strings . ToLower ( http . StatusText ( http . StatusInternalServerError ) ) ) }
DetectError wraps the provided error with additional information
useful for applications.
DetectError wraps the provided error with additional information useful for applications .