Print errors on config file load
This commit is contained in:
parent
896a9f79d1
commit
4baa6a6973
@ -98,17 +98,26 @@ private func createFileIfNeeded(at path: URL) throws {
|
||||
try Data().write(to: path)
|
||||
}
|
||||
|
||||
private func readConfig(at path: URL) throws -> URL {
|
||||
do {
|
||||
let logPath = try String(contentsOf: path)
|
||||
.trimmingCharacters(in: .whitespaces)
|
||||
return URL(fileURLWithPath: logPath)
|
||||
} catch {
|
||||
log("Failed to read configuration file at \(path.path): \(error)")
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// configures your application
|
||||
public func configure(_ app: Application) throws {
|
||||
// uncomment to serve files from /Public folder
|
||||
// app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
|
||||
app.http.server.configuration.port = 9001
|
||||
|
||||
let configFile = URL(fileURLWithPath: app.directory.resourcesDirectory)
|
||||
let configPath = URL(fileURLWithPath: app.directory.resourcesDirectory)
|
||||
.appendingPathComponent("paths.conf")
|
||||
let logPath = try String(contentsOf: configFile)
|
||||
.trimmingCharacters(in: .whitespaces)
|
||||
let logFile = URL(fileURLWithPath: logPath)
|
||||
let logFile = try readConfig(at: configPath)
|
||||
let listDirectory = URL(fileURLWithPath: app.directory.publicDirectory)
|
||||
.appendingPathComponent("lists")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user