You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Motivation
Fixesapple/swift-openapi-generator#730.
We were not correctly keeping `CustomStringConvertible` and
`LocalizedError` conformances separate for wrapper errors like
`ClientError` and `ServerError`. This lead to some user-thrown errors
(in handlers, transports, and middlewares) to print less information
than the error was actually providing (using a different method).
### Modifications
Properly untangle the two printing codepaths, and only call
`localizedDescription` from the wrapper error's `errorDescription`.
Also made the `localizedDescription` strings a bit more user-friendly
and less detailed, as in some apps these errors might get directly
rendered by a UI component that calls `localizedDescription`.
### Result
Error logging should now match adopter expectations.
### Test Plan
Added unit tests for `{Client,Server}Error` printing methods.
/// This computed property provides a localized human-readable description of the client error, which is suitable for displaying to users.
134
132
///
135
133
/// - Returns: A localized string describing the client error.
136
-
publicvarerrorDescription:String?{ description }
134
+
publicvarerrorDescription:String?{
135
+
"Client encountered an error invoking the operation \"\(operationID)\", caused by \"\(causeDescription)\", underlying error: \(underlyingError.localizedDescription)."
/// This computed property provides a localized human-readable description of the server error, which is suitable for displaying to users.
107
105
///
108
106
/// - Returns: A localized string describing the server error.
109
-
publicvarerrorDescription:String?{ description }
107
+
publicvarerrorDescription:String?{
108
+
"Server encountered an error handling the operation \"\(operationID)\", caused by \"\(causeDescription)\", underlying error: \(underlyingError.localizedDescription)."
0 commit comments