summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadLogging/Error+LogFormat.swift
blob: 6c1285936cb7eacae4a112b1e669b4da289a9786 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//
//  Error+LogFormat.swift
//  MullvadLogging
//
//  Created by pronebird on 26/09/2022.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import Foundation
import MullvadTypes

extension Error {
    public func logFormatError() -> String {
        let nsError = self as NSError
        var message = ""

        let description =
            (self as? CustomErrorDescriptionProtocol)?
            .customErrorDescription ?? localizedDescription

        message += "\(description) (domain = \(nsError.domain), code = \(nsError.code))"

        return message
    }
}