Add error handling
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
This commit is contained in:
32
Sources/ResgenSwift/Analytics/AnalyticsError.swift
Normal file
32
Sources/ResgenSwift/Analytics/AnalyticsError.swift
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// AnalyticsError.swift
|
||||
//
|
||||
//
|
||||
// Created by Loris Perret on 11/12/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
enum AnalyticsError: Error {
|
||||
case fileNotExists(String)
|
||||
case missingElement(String)
|
||||
case invalidParameter(String)
|
||||
|
||||
case writeFile(String, String)
|
||||
|
||||
var description: String {
|
||||
switch self {
|
||||
case .fileNotExists(let filename):
|
||||
return "error: [\(Analytics.toolName)] File \(filename) does not exists "
|
||||
|
||||
case .missingElement(let element):
|
||||
return "error: [\(Analytics.toolName)] Missing \(element) for Matomo"
|
||||
|
||||
case .invalidParameter(let reason):
|
||||
return "error: [\(Analytics.toolName)] Invalid parameter \(reason)"
|
||||
|
||||
case .writeFile(let subErrorDescription, let filename):
|
||||
return "error: [\(Analytics.toolName)] An error occured while writing content to \(filename): \(subErrorDescription)"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user