35 lines
671 B
Swift
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
|
|
}
|
|
}
|
|
}
|
|
|