Caps-Server/Sources/App/Error.swift
2022-06-24 11:31:09 +02:00

67 lines
1.0 KiB
Swift

//
// Error.swift
// App
//
// Created by Christoph on 17.05.20.
//
import Foundation
import Vapor
enum CapError: Error {
/**
HTTP Code: 404
*/
case unknownId
/**
HTTP Code: 400
*/
case invalidBody
/**
HTTP Code: 409
*/
case dataInconsistency
/**
HTTP Code: 412
*/
case invalidFile
/**
HTTP Code: 500
*/
case invalidConfiguration
/**
HTTP Code: 406
*/
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
}
}
}