-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: error handling changes in geo and geo test suite (#3256)
- Loading branch information
Showing
6 changed files
with
110 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
AmplifyPlugins/Geo/Sources/AWSLocationGeoPlugin/Support/Utils/GeoErrorConvertible.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Amplify | ||
import Foundation | ||
import AWSLocation | ||
import AWSClientRuntime | ||
|
||
protocol GeoErrorConvertible { | ||
var geoError: Geo.Error { get } | ||
} | ||
|
||
extension AWSLocation.AccessDeniedException: GeoErrorConvertible { | ||
var geoError: Geo.Error { | ||
.accessDenied( | ||
message ?? "", | ||
GeoPluginErrorConstants.accessDenied, | ||
self | ||
) | ||
} | ||
} | ||
|
||
extension AWSLocation.InternalServerException: GeoErrorConvertible { | ||
var geoError: Geo.Error { | ||
.serviceError( | ||
message ?? "", | ||
GeoPluginErrorConstants.internalServer, | ||
self | ||
) | ||
} | ||
} | ||
|
||
extension AWSLocation.ResourceNotFoundException: GeoErrorConvertible { | ||
var geoError: Geo.Error { | ||
.serviceError( | ||
message ?? "", | ||
GeoPluginErrorConstants.resourceNotFound, | ||
self | ||
) | ||
} | ||
} | ||
|
||
extension AWSLocation.ThrottlingException: GeoErrorConvertible { | ||
var geoError: Geo.Error { | ||
.serviceError( | ||
message ?? "", | ||
GeoPluginErrorConstants.throttling, | ||
self | ||
) | ||
} | ||
} | ||
|
||
extension AWSLocation.ValidationException: GeoErrorConvertible { | ||
var geoError: Geo.Error { | ||
.serviceError( | ||
message ?? "", | ||
GeoPluginErrorConstants.validation, | ||
self | ||
) | ||
} | ||
} | ||
|
||
extension AWSClientRuntime.UnknownAWSHTTPServiceError: GeoErrorConvertible { | ||
var geoError: Geo.Error { | ||
.unknown( | ||
""" | ||
Unknown service error occured with: | ||
- status: \(httpResponse.statusCode) | ||
- message: \(message ?? "") | ||
""", | ||
"", | ||
self | ||
) | ||
} | ||
} |
63 changes: 0 additions & 63 deletions
63
AmplifyPlugins/Geo/Sources/AWSLocationGeoPlugin/Support/Utils/GeoErrorHelper.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters