Skip to content

Sentry NSError in Swift #5390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
620078782D3906BF0022CB67 /* SentryCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 620078772D3906BF0022CB67 /* SentryCodableTests.swift */; };
620379DB2AFE1415005AC0C1 /* SentryBuildAppStartSpans.h in Headers */ = {isa = PBXBuildFile; fileRef = 620379DA2AFE1415005AC0C1 /* SentryBuildAppStartSpans.h */; };
620379DD2AFE1432005AC0C1 /* SentryBuildAppStartSpans.m in Sources */ = {isa = PBXBuildFile; fileRef = 620379DC2AFE1432005AC0C1 /* SentryBuildAppStartSpans.m */; };
620467AC2D3FFD230025F06C /* SentryNSErrorCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 620467AB2D3FFD1C0025F06C /* SentryNSErrorCodable.swift */; };
6205B4A42CE73AA100744684 /* TestDebugImageProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85790282976A69F00C6AC1F /* TestDebugImageProvider.swift */; };
6205CF262D549D8A001E6049 /* SentryDateCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6205CF252D549D8A001E6049 /* SentryDateCodableTests.swift */; };
621655662DB12A8900810504 /* SentryCrashMach-OTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 621655652DB12A8900810504 /* SentryCrashMach-OTests.m */; };
Expand Down Expand Up @@ -386,8 +385,6 @@
7B3398652459C15200BD9C96 /* SentryEnvelopeRateLimit.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B3398642459C15200BD9C96 /* SentryEnvelopeRateLimit.m */; };
7B3398672459C4AE00BD9C96 /* SentryEnvelopeRateLimitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3398662459C4AE00BD9C96 /* SentryEnvelopeRateLimitTests.swift */; };
7B34721728086A9D0041F047 /* SentrySwizzleWrapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B34721628086A9D0041F047 /* SentrySwizzleWrapperTests.swift */; };
7B3B473025D6CBFC00D01640 /* SentryNSError.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B3B472F25D6CBFC00D01640 /* SentryNSError.h */; settings = {ATTRIBUTES = (Public, ); }; };
7B3B473825D6CC7E00D01640 /* SentryNSError.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B3B473725D6CC7E00D01640 /* SentryNSError.m */; };
7B3B473E25D6CEA500D01640 /* SentryNSErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3B473D25D6CEA500D01640 /* SentryNSErrorTests.swift */; };
7B42C48027E08F33009B58C2 /* SentryDependencyContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B42C47F27E08F33009B58C2 /* SentryDependencyContainer.h */; settings = {ATTRIBUTES = (Private, ); }; };
7B42C48227E08F4B009B58C2 /* SentryDependencyContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B42C48127E08F4B009B58C2 /* SentryDependencyContainer.m */; };
Expand Down Expand Up @@ -1062,8 +1059,9 @@
FA67DD182DDBD4EA00896B02 /* UIImageHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCED2DDBD4EA00896B02 /* UIImageHelper.swift */; };
FA67DD192DDBD4EA00896B02 /* SwizzleClassNameExclude.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCD52DDBD4EA00896B02 /* SwizzleClassNameExclude.swift */; };
FA8A36182DEAA1EB0058D883 /* SentryThread+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */; };
FAEC273D2DF3933A00878871 /* NSData+Unzip.m in Sources */ = {isa = PBXBuildFile; fileRef = FAEC273C2DF3933200878871 /* NSData+Unzip.m */; };
FA8DEC2E2DF7F2D000C25374 /* SentryNSError.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8DEC2D2DF7F2D000C25374 /* SentryNSError.swift */; };
FAEC270E2DF3526000878871 /* SentryUserFeedback.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */; };
FAEC273D2DF3933A00878871 /* NSData+Unzip.m in Sources */ = {isa = PBXBuildFile; fileRef = FAEC273C2DF3933200878871 /* NSData+Unzip.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -1223,7 +1221,6 @@
620078772D3906BF0022CB67 /* SentryCodableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCodableTests.swift; sourceTree = "<group>"; };
620379DA2AFE1415005AC0C1 /* SentryBuildAppStartSpans.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryBuildAppStartSpans.h; path = include/SentryBuildAppStartSpans.h; sourceTree = "<group>"; };
620379DC2AFE1432005AC0C1 /* SentryBuildAppStartSpans.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBuildAppStartSpans.m; sourceTree = "<group>"; };
620467AB2D3FFD1C0025F06C /* SentryNSErrorCodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryNSErrorCodable.swift; sourceTree = "<group>"; };
6205CF252D549D8A001E6049 /* SentryDateCodableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryDateCodableTests.swift; sourceTree = "<group>"; };
621655652DB12A8900810504 /* SentryCrashMach-OTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SentryCrashMach-OTests.m"; sourceTree = "<group>"; };
621AE74A2C626C230012E730 /* SentryANRTrackerV2.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryANRTrackerV2.h; path = include/SentryANRTrackerV2.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1544,8 +1541,6 @@
7B3398662459C4AE00BD9C96 /* SentryEnvelopeRateLimitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelopeRateLimitTests.swift; sourceTree = "<group>"; };
7B34721628086A9D0041F047 /* SentrySwizzleWrapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySwizzleWrapperTests.swift; sourceTree = "<group>"; };
7B3878E92490D90400EBDEA2 /* SentryClient+TestInit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryClient+TestInit.h"; sourceTree = "<group>"; };
7B3B472F25D6CBFC00D01640 /* SentryNSError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryNSError.h; path = Public/SentryNSError.h; sourceTree = "<group>"; };
7B3B473725D6CC7E00D01640 /* SentryNSError.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryNSError.m; sourceTree = "<group>"; };
7B3B473D25D6CEA500D01640 /* SentryNSErrorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryNSErrorTests.swift; sourceTree = "<group>"; };
7B42C47F27E08F33009B58C2 /* SentryDependencyContainer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDependencyContainer.h; path = include/HybridPublic/SentryDependencyContainer.h; sourceTree = "<group>"; };
7B42C48127E08F4B009B58C2 /* SentryDependencyContainer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDependencyContainer.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2304,6 +2299,7 @@
FA67DCEF2DDBD4EA00896B02 /* URLSessionTaskHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionTaskHelper.swift; sourceTree = "<group>"; };
FA67DCF22DDBD4EA00896B02 /* SwiftDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptor.swift; sourceTree = "<group>"; };
FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryThread+Private.h"; path = "include/SentryThread+Private.h"; sourceTree = "<group>"; };
FA8DEC2D2DF7F2D000C25374 /* SentryNSError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryNSError.swift; sourceTree = "<group>"; };
FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUserFeedback.swift; sourceTree = "<group>"; };
FAEC273C2DF3933200878871 /* NSData+Unzip.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+Unzip.m"; sourceTree = "<group>"; };
FAEC273E2DF393E000878871 /* NSData+Unzip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSData+Unzip.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2404,11 +2400,11 @@
children = (
623FD9032D3FA90900803EDA /* NSNumberDecodableWrapper.swift */,
6281C5712D3E4F06009D0978 /* DecodeArbitraryData.swift */,
FA8DEC2D2DF7F2D000C25374 /* SentryNSError.swift */,
623FD9012D3FA5DA00803EDA /* SentryFrameCodable.swift */,
6293F5742D422A8A002BC3BD /* SentryStacktraceCodable.swift */,
62F70E922D4234B100634054 /* SentryMechanismMetaCodable.swift */,
62F70E942D423BCA00634054 /* SentryMechanismCodable.swift */,
620467AB2D3FFD1C0025F06C /* SentryNSErrorCodable.swift */,
620078712D38F00D0022CB67 /* SentryGeoCodable.swift */,
628094732D39584700B3F18B /* SentryUserCodable.swift */,
627C77882D50B6840055E966 /* SentryBreadcrumbCodable.swift */,
Expand Down Expand Up @@ -2537,8 +2533,6 @@
6334314020AD9AE40077E581 /* SentryMechanism.m */,
7BECF42126145C5D00D9826E /* SentryMechanismMeta.h */,
7BECF42726145CD900D9826E /* SentryMechanismMeta.m */,
7B3B472F25D6CBFC00D01640 /* SentryNSError.h */,
7B3B473725D6CC7E00D01640 /* SentryNSError.m */,
639FCFA61EBC80CC00778193 /* SentryFrame.h */,
639FCFA71EBC80CC00778193 /* SentryFrame.m */,
639FCFA21EBC809A00778193 /* SentryStacktrace.h */,
Expand Down Expand Up @@ -4716,7 +4710,6 @@
7BD4BD4727EB2A3D0071F4FF /* SentryDiscardedEvent.h in Headers */,
7BBD18972449DC1D00427C76 /* SentryRateLimits.h in Headers */,
844EDC76294144DB00C86F34 /* SentrySystemWrapper.h in Headers */,
7B3B473025D6CBFC00D01640 /* SentryNSError.h in Headers */,
630436101EC0600A00C4D3FA /* SentrySerializable.h in Headers */,
63FE70DD20DA4C1000CDBAE8 /* SentryCrashMonitor_Signal.h in Headers */,
63FE710320DA4C1000CDBAE8 /* SentryCrashMachineContext_Apple.h in Headers */,
Expand Down Expand Up @@ -5264,7 +5257,6 @@
7B7D873624864C9D00D2ECFF /* SentryCrashDefaultMachineContextWrapper.m in Sources */,
63FE712F20DA4C1100CDBAE8 /* SentryCrashSysCtl.c in Sources */,
62212B872D520CB00062C2FA /* SentryEventCodable.swift in Sources */,
7B3B473825D6CC7E00D01640 /* SentryNSError.m in Sources */,
621AE74D2C626C510012E730 /* SentryANRTrackerV2.m in Sources */,
84CFA4CA2C9DF884008DA5F4 /* SentryUserFeedbackWidget.swift in Sources */,
FAEC270E2DF3526000878871 /* SentryUserFeedback.swift in Sources */,
Expand Down Expand Up @@ -5468,6 +5460,7 @@
D8739D182BEEA33F007D2F66 /* SentryLevelHelper.m in Sources */,
63FE712720DA4C1000CDBAE8 /* SentryCrashThread.c in Sources */,
7B127B0F27CF6F4700A71ED2 /* SentryANRTrackingIntegration.m in Sources */,
FA8DEC2E2DF7F2D000C25374 /* SentryNSError.swift in Sources */,
62C316832B1F2EA1000D7031 /* SentryDelayedFramesTracker.m in Sources */,
D8BFE37329A3782F002E73F3 /* SentryTimeToDisplayTracker.m in Sources */,
15360CCF2432777500112302 /* SentrySessionTracker.m in Sources */,
Expand All @@ -5477,7 +5470,6 @@
F452437E2DE60B71003E8F50 /* SentryUseNSExceptionCallstackWrapper.m in Sources */,
63FE70D320DA4C1000CDBAE8 /* SentryCrashMonitor_AppState.c in Sources */,
849B8F9D2C6E906900148E1F /* SentryUserFeedbackWidgetConfiguration.swift in Sources */,
620467AC2D3FFD230025F06C /* SentryNSErrorCodable.swift in Sources */,
639FCFA51EBC809A00778193 /* SentryStacktrace.m in Sources */,
D84D2CC32C29AD120011AF8A /* SentrySessionReplay.swift in Sources */,
849B8F9B2C6E906900148E1F /* SentryUserFeedbackIntegrationDriver.swift in Sources */,
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/Public/Sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ FOUNDATION_EXPORT const unsigned char SentryVersionString[];
# import <Sentry/SentryMechanism.h>
# import <Sentry/SentryMechanismMeta.h>
# import <Sentry/SentryMessage.h>
# import <Sentry/SentryNSError.h>
# import <Sentry/SentryOptions.h>
# import <Sentry/SentryReplayApi.h>
# import <Sentry/SentryRequest.h>
Expand Down
38 changes: 0 additions & 38 deletions Sources/Sentry/Public/SentryNSError.h

This file was deleted.

1 change: 0 additions & 1 deletion Sources/Sentry/Public/SentryWithoutUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ FOUNDATION_EXPORT const unsigned char SentryVersionString[];
# import <SentryWithoutUIKit/SentryMechanism.h>
# import <SentryWithoutUIKit/SentryMechanismMeta.h>
# import <SentryWithoutUIKit/SentryMessage.h>
# import <SentryWithoutUIKit/SentryNSError.h>
# import <SentryWithoutUIKit/SentryOptions.h>
# import <SentryWithoutUIKit/SentryReplayApi.h>
# import <SentryWithoutUIKit/SentryRequest.h>
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/SentryClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#import "SentryMeta.h"
#import "SentryMsgPackSerializer.h"
#import "SentryNSDictionarySanitize.h"
#import "SentryNSError.h"
#import "SentryOptions+Private.h"
#import "SentryPropagationContext.h"
#import "SentryRandom.h"
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/SentryMechanism.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#import "NSMutableDictionary+Sentry.h"
#import "SentryMechanismMeta.h"
#import "SentryNSDictionarySanitize.h"
#import "SentryNSError.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryMechanismMeta.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "SentryMechanismMeta.h"
#import "SentryNSDictionarySanitize.h"
#import "SentryNSError.h"
#import "SentrySwift.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
24 changes: 0 additions & 24 deletions Sources/Sentry/SentryNSError.m

This file was deleted.

39 changes: 39 additions & 0 deletions Sources/Swift/Protocol/Codable/SentryNSError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Foundation

/// Sentry representation of an NSError to send to Sentry.
@objcMembers
open class SentryNSError: NSObject, SentrySerializable, Decodable {

/// The domain of an NSError.
open var domain: String

/// The error code of an NSError.
open var code: Int

/// Initializes SentryNSError and sets the domain and code.
/// - Parameters:
/// - domain: The domain of an NSError.
/// - code: The error code of an NSError.
public init(domain: String, code: Int) {
self.domain = domain
self.code = code
super.init()

Check warning on line 20 in Sources/Swift/Protocol/Codable/SentryNSError.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Protocol/Codable/SentryNSError.swift#L17-L20

Added lines #L17 - L20 were not covered by tests
}

open func serialize() -> [String: Any] {
return ["domain": domain, "code": code]

Check warning on line 24 in Sources/Swift/Protocol/Codable/SentryNSError.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Protocol/Codable/SentryNSError.swift#L23-L24

Added lines #L23 - L24 were not covered by tests
}

enum CodingKeys: String, CodingKey {
case domain
case code
}

required convenience public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

let domain = try container.decode(String.self, forKey: .domain)
let code = try container.decode(Int.self, forKey: .code)
self.init(domain: domain, code: code)

Check warning on line 37 in Sources/Swift/Protocol/Codable/SentryNSError.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Protocol/Codable/SentryNSError.swift#L32-L37

Added lines #L32 - L37 were not covered by tests
}
}
18 changes: 0 additions & 18 deletions Sources/Swift/Protocol/Codable/SentryNSErrorCodable.swift

This file was deleted.

1 change: 0 additions & 1 deletion Tests/SentryTests/SentryTests-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
#import "SentryNSDataUtils.h"
#import "SentryNSDictionarySanitize+Tests.h"
#import "SentryNSDictionarySanitize.h"
#import "SentryNSError.h"
#import "SentryNSNotificationCenterWrapper.h"
#import "SentryNSProcessInfoWrapper.h"
#import "SentryNSTimerFactory.h"
Expand Down
Loading
Loading