Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gagnant committed Nov 26, 2016
1 parent cb0b55d commit c8d389c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion JSTP.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'JSTP'
s.version = '0.1.9'
s.version = '0.1.9.1'
s.license = { :type => "MIT" }

s.homepage = 'https://github.com/metarhia/JSTP'
Expand Down
30 changes: 24 additions & 6 deletions JSTP/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ internal extension NSError {

internal convenience init?(_ object: Any) {

guard let data = object as? [Any],
let code = data[0] as? Int else {

guard let data = object as? [Any],
let code = data[0] as? Int,
let description = data[1] as? String else {

return nil
}

var description: String!

self.init(code, description)
if data.count == 2 {
description = data[1] as? String
}

description = description ?? Errors.kErrors[code] ?? "Undefined error"

self.init(code, description)
}

internal func raw() -> AnyObject {
Expand All @@ -49,6 +54,19 @@ open class Errors {
open static let ApplicationNotFound = NSError(10, "Application not found" )
open static let AuthorizationFailed = NSError(11, "Authentication failed" )
open static let InterfaceNotFound = NSError(12, "Interface not found" )
open static let InternalError = NSError(16, "Internal API error" )
open static let MethodNotFound = NSError(14, "Method not found" )
open static let NotSerever = NSError(15, "Not a server" )

fileprivate static let kErrors = [

13: "Incompatible interface",
10: "Application not found",
11: "Authentication failed",
12: "Interface not found",
16: "Internal API error",
14: "Method not found",
15: "Not a server",
]

}

0 comments on commit c8d389c

Please sign in to comment.