mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-08 22:33:26 +01:00
[Shared] Fixes pattern matching non-ALTErrorEnum error codes
This commit is contained in:
@@ -427,6 +427,37 @@ extension AltTests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testPatternMatchingErrorCode() async throws
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// ALTLocalizedError
|
||||||
|
throw OperationError.serverNotFound
|
||||||
|
}
|
||||||
|
catch ~OperationError.Code.serverNotFound
|
||||||
|
{
|
||||||
|
// Success
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
XCTFail("Failed to catch error as OperationError.Code.serverNotFound: \(error)")
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// ALTErrorEnum
|
||||||
|
throw AuthenticationError(.noTeam)
|
||||||
|
}
|
||||||
|
catch ~AuthenticationErrorCode.noTeam
|
||||||
|
{
|
||||||
|
// Success
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
XCTFail("Failed to catch error as AuthenticationErrorCode.noTeam: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testWithLocalizedTitle() async throws
|
func testWithLocalizedTitle() async throws
|
||||||
{
|
{
|
||||||
let localizedTitle = "AltTest Failed"
|
let localizedTitle = "AltTest Failed"
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public extension ALTErrorCode
|
|||||||
{
|
{
|
||||||
static var errorDomain: String {
|
static var errorDomain: String {
|
||||||
let typeName = String(reflecting: Self.self) // "\(Self.self)" doesn't include module name, but String(reflecting:) does.
|
let typeName = String(reflecting: Self.self) // "\(Self.self)" doesn't include module name, but String(reflecting:) does.
|
||||||
let errorDomain = typeName.replacingOccurrences(of: "ErrorCode", with: "Error")
|
let errorDomain = typeName.replacingOccurrences(of: "ErrorCode", with: "Error").replacingOccurrences(of: "Error.Code", with: "Error")
|
||||||
return errorDomain
|
return errorDomain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user