Caps-Server/Sources/App/Error.swift
2022-05-28 21:59:32 +02:00

38 lines
757 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
case invalidData
var response: HTTPResponseStatus {
switch self {
/// 404
case .unknownId: return .notFound
/// 400
case .invalidBody: return .badRequest
/// 406
case .invalidData: return .notAcceptable
/// 409
case .dataInconsistency: return .conflict
/// 412
case .invalidFile: return .preconditionFailed
/// 500
case .invalidConfiguration: return .internalServerError
}
}
}