TM-SGNL-iOS/SignalServiceKit/Util/Error+SSK.swift
TeleMessage developers dde0620daf initial commit
2025-05-03 12:28:28 -07:00

25 lines
803 B
Swift

//
// Copyright 2019 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import Foundation
public extension Error {
/// A description comprised of "domain/code" pairs for this error and its underlying errors.
var shortDescription: String { (self as NSError).shortDescription }
}
@objc
public extension NSError {
/// A description comprised of "domain/code" pairs for this error and its underlying errors.
var shortDescription: String {
var result = [String]()
var nextError: NSError? = self
while let currentError = nextError {
result.append("\(currentError.domain)/\(currentError.code)")
nextError = currentError.userInfo[NSUnderlyingErrorKey] as? NSError
}
return result.joined(separator: ", ")
}
}