Skip to content

Commit

Permalink
Fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Gayathri Sairamkrishnan committed Nov 20, 2024
1 parent a4f5df4 commit 4e7c638
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ import HTTPTypes
/// ```
/// - Note: The placement of ``ErrorHandlingMiddleware`` in the middleware chain is important. It should be determined based on the specific needs of each application. Consider the order of execution and dependencies between middlewares.
public struct ErrorHandlingMiddleware: ServerMiddleware {

/// Creates a new middleware.
public init() {}

// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
public func intercept(
_ request: HTTPTypes.HTTPRequest,
Expand All @@ -58,7 +56,9 @@ public struct ErrorHandlingMiddleware: ServerMiddleware {
async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?)
) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) {
do { return try await next(request, body, metadata) } catch {
if let serverError = error as? ServerError, let appError = serverError.underlyingError as? (any HTTPResponseConvertible) {
if let serverError = error as? ServerError,
let appError = serverError.underlyingError as? (any HTTPResponseConvertible)
{
return (
HTTPResponse(status: appError.httpStatus, headerFields: appError.httpHeaderFields),
appError.httpBody
Expand Down

0 comments on commit 4e7c638

Please sign in to comment.