From 62d4b1483b850da0a99c2aa6c2da8b013e308f50 Mon Sep 17 00:00:00 2001 From: Damian Rzeszot Date: Mon, 9 Oct 2017 11:56:50 +0200 Subject: [PATCH] swift | fix style guidelines --- ru-ru/swift-ru.html.markdown | 8 ++++---- swift.html.markdown | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ru-ru/swift-ru.html.markdown b/ru-ru/swift-ru.html.markdown index 7ff660e1..46a91660 100644 --- a/ru-ru/swift-ru.html.markdown +++ b/ru-ru/swift-ru.html.markdown @@ -376,14 +376,14 @@ print("Имя :\(name)") // Имя: Яков // Протокол `Error` используется для перехвата выбрасываемых ошибок enum MyError: Error { - case BadValue(msg: String) - case ReallyBadValue(msg: String) + case badValue(msg: String) + case reallyBadValue(msg: String) } // фунции помеченные словом `throws` должны вызываться с помощью `try` func fakeFetch(value: Int) throws -> String { guard 7 == value else { - throw MyError.ReallyBadValue(msg: "Действительно плохое значение") + throw MyError.reallyBadValue(msg: "Действительно плохое значение") } return "тест" @@ -401,7 +401,7 @@ func testTryStuff() { do { // обычно try оператор, позволяющий обработать ошибку в `catch` блоке try fakeFetch(value: 1) - } catch MyError.BadValue(let msg) { + } catch MyError.badValue(let msg) { print("Ошибка: \(msg)") } catch { // все остальное diff --git a/swift.html.markdown b/swift.html.markdown index 60915d72..46388ca5 100644 --- a/swift.html.markdown +++ b/swift.html.markdown @@ -361,14 +361,14 @@ print("Name is \(name)") // Name is Them // The `Error` protocol is used when throwing errors to catch enum MyError: Error { - case BadValue(msg: String) - case ReallyBadValue(msg: String) + case badValue(msg: String) + case reallyBadValue(msg: String) } // functions marked with `throws` must be called using `try` func fakeFetch(value: Int) throws -> String { guard 7 == value else { - throw MyError.ReallyBadValue(msg: "Some really bad value") + throw MyError.reallyBadValue(msg: "Some really bad value") } return "test" @@ -385,7 +385,7 @@ func testTryStuff() { do { // normal try operation that provides error handling via `catch` block try fakeFetch(value: 1) - } catch MyError.BadValue(let msg) { + } catch MyError.badValue(let msg) { print("Error message: \(msg)") } catch { // must be exhaustive