File tree Expand file tree Collapse file tree
Tests/ErrorMiddlewareTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ concurrency:
1515jobs :
1616 analyze :
1717 name : Analyze
18- runs-on : macos-15
18+ runs-on : macos-26
1919 permissions :
2020 security-events : write
2121
3535
3636 - name : Build
3737 run : swift build
38-
38+
3939 - name : Perform CodeQL Analysis
4040 uses : github/codeql-action/analyze@v4
41-
Original file line number Diff line number Diff line change 1818 environment :
1919 name : github-pages
2020 url : ${{ steps.deployment.outputs.page_url }}
21- runs-on : macos-15
21+ runs-on : macos-26
2222
2323 steps :
2424 - name : Checkout 🛎️
Original file line number Diff line number Diff line change 1717 - name : Select Xcode
1818 uses : maxim-lobanov/setup-xcode@v1
1919 with :
20- xcode-version : " 16.3.0 "
20+ xcode-version : latest-stable
2121
2222 - name : Install SwiftLint
2323 run : brew install swiftlint
2626 run : swiftlint version
2727
2828 - name : Run SwiftLint
29- run : swiftlint --strict -- config .swiftlint.yml
29+ run : swiftlint --config .swiftlint.yml
Original file line number Diff line number Diff line change 2626 - name : Select Xcode
2727 uses : maxim-lobanov/setup-xcode@v1
2828 with :
29- xcode-version : " 16.3.0 "
29+ xcode-version : latest-stable
3030 - name : Cache SwiftPM
3131 uses : actions/cache@v4
3232 with :
@@ -38,14 +38,22 @@ jobs:
3838 ${{ runner.os }}-spm-
3939 - name : Build
4040 run : swift build -v
41- - name : Test (parallel)
42- run : swift test -v --parallel
41+ - name : Run tests
42+ run : swift test -v --enable-code-coverage
43+ - name : Fetch Coverage
44+ id : coverage-files
45+ uses : sersoft-gmbh/swift-coverage-action@v4
46+ - name : Publish Coverage to Codecov
47+ uses : codecov/codecov-action@v4.0.1
48+ with :
49+ token : ${{ secrets.CODECOV_TOKEN }}
50+ files : ${{ steps.coverage-files.outputs.files }}
4351 # =========================
4452 # Linux
4553 # =========================
4654 linux :
4755 runs-on : ubuntu-latest
48- container : swift:6.0 -jammy
56+ container : swift:6.2 -jammy
4957 steps :
5058 - name : Checkout
5159 uses : actions/checkout@v4
5866 linux-spm-
5967 - name : Build
6068 run : swift build -v
61- - name : Test (parallel)
62- run : swift test -v --parallel
69+ - name : Run tests
70+ run : swift test
Original file line number Diff line number Diff line change 1- // swift-tools-version: 6.0
1+ // swift-tools-version: 6.2
22// The swift-tools-version declares the minimum version of Swift required to build this package.
33
44import PackageDescription
55
66let package = Package (
77 name: " fs-error-middleware " ,
88 platforms: [
9- . macOS( . v13 )
9+ . macOS( . v15 )
1010 ] ,
1111 products: [
1212 // Products define the executables and libraries a package produces, and make them visible to other packages.
@@ -17,7 +17,7 @@ let package = Package(
1717 ] ,
1818 dependencies: [
1919 // 💧 A server-side Swift web framework.
20- . package ( url: " https://github.com/vapor/vapor.git " , from: " 4.115 .0 " ) ,
20+ . package ( url: " https://github.com/vapor/vapor.git " , from: " 4.120 .0 " ) ,
2121 // 📄 Swift-DocC plugin for generating documentation.
2222 . package ( url: " https://github.com/apple/swift-docc-plugin.git " , from: " 1.0.0 " ) ,
2323 ] ,
Original file line number Diff line number Diff line change @@ -28,11 +28,7 @@ import Foundation
2828/// Extension for ErrorMiddleware.
2929public extension ErrorMiddleware {
3030 /// Creates a custom `ErrorMiddleware` for handling errors in a Vapor application.
31- ///
32- /// This function provides a tailored error handling mechanism based on the application's environment
33- /// and an additional numeric identifier. It categorizes errors into specific cases, assigns appropriate
34- /// HTTP status codes, and generates error responses in JSON format.
35- ///
31+ ///
3632 /// - Parameters:
3733 /// - environment: The current `Environment` of the application, used to determine error visibility and debugging details.
3834 /// - number: An additional numeric identifier to uniquely identify error codes.
Original file line number Diff line number Diff line change @@ -33,6 +33,17 @@ struct ErrorMiddlewareTests {
3333 }
3434 try await app. asyncShutdown ( )
3535 }
36+
37+ @Test ( " Error middleware success " )
38+ func errorMiddlewareSuccess( ) async throws {
39+ try await withApp { app in
40+ app. middleware. use ( ErrorMiddleware . custom ( environment: app. environment, for: 1 ) )
41+
42+ try await app. test ( . POST, " order " ) { res throws in
43+ #expect( res. status == . ok)
44+ }
45+ }
46+ }
3647
3748 @Test ( " Error middleware snake case " )
3849 func errorMiddlewareSnakeCase( ) async throws {
You can’t perform that action at this time.
0 commit comments