 
     // MARK: - Validations
 
-    func validateUrl(_ url: String) {
+    func validateUrl(_ url: String) throws {
         guard url.isValidUrl else {
-             fatalError("invalid url")
-        }
-    }
-    
-    func validateKey(_ key: String, description: String) {
+             throw RatingError.validation(message: "invalid url")
+        }
+    }
+    
+    func validateKey(_ key: String, description: String) throws {
         guard key.length == 32 else {
-            fatalError("\(description) is not a valid key")
-        }
-    }
-    
-    func validateToken(_ token: String) {
+            throw RatingError.validation(message: "\(description) is not a valid key")
+        }
+    }
+    
+    func validateToken(_ token: String) throws {
         guard token.length > 0 else {
-            fatalError("invalid token")
+            throw RatingError.validation(message: "invalid token")
         }
     }
     

        return result
    }
    
    func send(params: [String: Any]) {
        
    }
    
    // MARK: - Public API
    
    func create(rating: Int, description: String?, comment: String?) throws {
        try validateRating(rating)
        
        var params: [String: Any] = buildParams()

}

public class Rating {
    init(api url: String, app: String, platform: String, range: String, token: String) throws {
        let baseUrl = url.trimmed
        
        self.url = baseUrl.lastCharacterAsString == "/" ? baseUrl + "ratings" :  baseUrl + "/ratings"
        self.app = app.trimmed
        self.platform = platform.trimmed
        self.range = range.trimmed
        self.token = token.trimmed
        self.deviceInfo = GBDeviceInfo()
        
        try validateUrl(self.url)
        try validateKey(self.app, description: "app")
        try validateKey(self.platform, description: "platform")
        try validateKey(self.range, description: "range")
        try validateToken(self.token)
    }
    
    // MARK: - Private properties
