Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specific error message for when accessing a certificate file fails #241

Closed
rolson opened this issue Jan 6, 2023 · 3 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@rolson
Copy link
Contributor

rolson commented Jan 6, 2023

A PR was merged that fixed an issue with importing a certificate. However we need to follow up on that and make sure to have specific error message for the failure to access a certificate file.

@rolson rolson added the enhancement New feature or request label Jan 6, 2023
@rolson
Copy link
Contributor Author

rolson commented Jan 6, 2023

cc @carl8382

@rolson
Copy link
Contributor Author

rolson commented Jan 6, 2023

It might be useful to have a toolkit level specific error:

enum CertificateError: Error {
    case couldNotAccessSecureScopedResource
    case importError(CertificateImportError)
    case unknown
}

extension CertificateError {
    var message: String {
        switch self {
        case .couldNotAccessSecureScopedResource:
            return "Could not access certificate file."
        case .unknown:
            return "Unknown error accessing and importing the certificate."
        case .importError(let certificateImportError):
            switch certificateImportError {
            case .invalidData:
                return "The certificate file was invalid."
            case .invalidPassword:
                return "The password was invalid."
            default:
                return defaultMessage
            }
        }
    }
}

and use that instead of CertificateImportError

@dfeinzimer
Copy link
Collaborator

Completed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants