mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
Swift
43 lines
1.4 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
//
|
|
// stringlint:disable
|
|
|
|
import Foundation
|
|
import SessionUtil
|
|
|
|
public enum LibSessionError: LocalizedError {
|
|
case unableToCreateConfigObject
|
|
case nilConfigObject
|
|
case userDoesNotExist
|
|
case getOrConstructFailedUnexpectedly
|
|
case processingLoopLimitReached
|
|
case invalidCConversion
|
|
|
|
case libSessionError(String)
|
|
case unknown
|
|
|
|
public init(_ cError: [CChar]) {
|
|
self = LibSessionError.libSessionError(String(cString: cError))
|
|
}
|
|
|
|
public init(_ errorString: String) {
|
|
switch errorString {
|
|
default: self = LibSessionError.libSessionError(errorString)
|
|
}
|
|
}
|
|
|
|
public var errorDescription: String? {
|
|
switch self {
|
|
case .unableToCreateConfigObject: return "Unable to create config object."
|
|
case .nilConfigObject: return "Null config object."
|
|
case .userDoesNotExist: return "User does not exist."
|
|
case .getOrConstructFailedUnexpectedly: return "'getOrConstruct' failed unexpectedly."
|
|
case .processingLoopLimitReached: return "Processing loop limit reached."
|
|
case .invalidCConversion: return "Invalid conversation to C type."
|
|
|
|
case .libSessionError(let error): return "\(error)\(error.hasSuffix(".") ? "" : ".")"
|
|
case .unknown: return "An unknown error occurred."
|
|
}
|
|
}
|
|
}
|