aws-sdk-ios icon indicating copy to clipboard operation
aws-sdk-ios copied to clipboard

AWSMobileClientError message accessibility

Open nahung89 opened this issue 5 years ago • 2 comments

Which AWS Services is the feature request for? AWSMobileClient

Is your feature request related to a problem? Please describe. AWSMobileClientError supports message property, but the accessibility is internal. Therefore we can't get it from other modules.

Describe the solution you'd like add public for this property to expose it:

extension AWSMobileClientError {
    /// Underlying error message of `AWSMobileClientError`
    public var message: String { ... }

nahung89 avatar Nov 01 '19 04:11 nahung89

Up for this. I need to access this object. I think this is an intentional mistake? For now I'm going to unlock the pod, and add public keyword.

EDIT: A much better temporary solution, make an extension of the class, and make your own message object, like so:

//
//  AWSMobileClientError+Extension.swift
//  Project
//
//  Created by Glenn Posadas on 1/10/20.
//  Copyright © 2020 Glenn Posadas. All rights reserved.
//

import AWSMobileClient
import Foundation

extension AWSMobileClientError {
    /// Underlying error message of `AWSMobileClientError`
    var errorMessage: String {
        switch self {
        case .aliasExists(let message),
             .badRequest(let message),
             .codeDeliveryFailure(let message),
             .codeMismatch(let message),
             .cognitoIdentityPoolNotConfigured(let message),
             .deviceNotRemembered(let message),
             .errorLoadingPage(let message),
             .expiredCode(let message),
             .expiredRefreshToken(let message),
             .federationProviderExists(let message),
             .groupExists(let message),
             .guestAccessNotAllowed(let message),
             .idTokenAndAcceessTokenNotIssued(let message),
             .idTokenNotIssued(let message),
             .identityIdUnavailable(let message),
             .internalError(let message),
             .invalidConfiguration(let message),
             .invalidLambdaResponse(let message),
             .invalidOAuthFlow(let message),
             .invalidParameter(let message),
             .invalidPassword(let message),
             .invalidState(let message),
             .invalidUserPoolConfiguration(let message),
             .limitExceeded(let message),
             .mfaMethodNotFound(let message),
             .notAuthorized(let message),
             .notSignedIn(let message),
             .passwordResetRequired(let message),
             .resourceNotFound(let message),
             .scopeDoesNotExist(let message),
             .securityFailed(let message),
             .softwareTokenMFANotFound(let message),
             .tooManyFailedAttempts(let message),
             .tooManyRequests(let message),
             .unableToSignIn(let message),
             .unexpectedLambda(let message),
             .unknown(let message),
             .userCancelledSignIn(let message),
             .userLambdaValidation(let message),
             .userNotConfirmed(let message),
             .userNotFound(let message),
             .userPoolNotConfigured(let message),
             .usernameExists(let message):
            return message
        }
    }
}

glennposadas avatar Jan 09 '20 16:01 glennposadas

I was going to open exactly the same issue until I realised it was already done. This should be public.

Ricardo1980 avatar May 15 '21 12:05 Ricardo1980

There have been a lot of releases since the issue was opened. Would you be able to test this on the latest release?

harsh62 avatar Oct 03 '23 15:10 harsh62

Thanks for opening this issue. The message property has been made public -- this change will be included in the next release.

atierian avatar Dec 15 '23 21:12 atierian