Caps-Server/Sources/App/Error.swift
2021-11-08 21:58:55 +01:00

35 lines
671 B
Swift

//
// Error.swift
// App
//
// Created by Christoph on 17.05.20.
//
import Foundation
import Vapor
enum CapError: Error {
case unknownId
case invalidBody
case dataInconsistency
case invalidFile
case invalidConfiguration
var response: HTTPResponseStatus {
switch self {
/// 404
case .unknownId: return .notFound
/// 400
case .invalidBody: return .badRequest
/// 409
case .dataInconsistency: return .conflict
/// 412
case .invalidFile: return .preconditionFailed
/// 500
case .invalidConfiguration: return .internalServerError
}
}
}