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

Обработка серверных ошибок маппинга #175

Closed
petropavel13 opened this issue Jan 9, 2019 · 2 comments
Closed
Assignees

Comments

@petropavel13
Copy link
Contributor

Из гайда https://github.com/TouchInstinct/Styleguide/blob/master/IOS/Guides/Custom_Network_Service_Guide.md#обработка-ошибок-при-запросах

Актуализировать вот этот кусок кода:

extension Error {

    var requestError: RequestError? {
        return self as? RequestError
    }

    var serverError: ServerError? {
        switch requestError {
        case .mapping(_, let response)?:
            guard let json = try? cast(response) as [String: Any] else {
                return nil
            }

            return try? ServerError(JSON: json)
        default:
            return nil
        }
    }

}

И добавить это в LeadKit.

Вместо вычисляемой property serverError сделать функцию с generic параметром.

@petropavel13
Copy link
Contributor Author

  • актуализировать сам гайд

@ZharaOo
Copy link
Contributor

ZharaOo commented May 30, 2019

Готово

@ZharaOo ZharaOo closed this as completed May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants