Skip to content

Commit

Permalink
test: Add Error Description in iOS-Swift sample (#2813)
Browse files Browse the repository at this point in the history
Add custom error description when capturing swift errors.
  • Loading branch information
philipphofmann committed Mar 20, 2023
1 parent d80d410 commit 228a909
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/Tools/RandomErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ enum SampleError: Error {
case awesomeCentaur
}

extension SampleError: CustomNSError {
var errorUserInfo: [String: Any] {
func getDebugDescription() -> String {
switch self {
case SampleError.bestDeveloper:
return "bestDeveloper"
case .happyCustomer:
return "happyCustomer"
case .awesomeCentaur:
return "awesomeCentaur"
}
}

return [NSDebugDescriptionErrorKey: getDebugDescription()]
}
}

class RandomErrorGenerator {

static func generate() throws {
Expand Down

0 comments on commit 228a909

Please sign in to comment.