Caps-Server/Sources/App/Error.swift

32 lines
561 B
Swift
Raw Normal View History

2020-05-19 15:19:19 +02:00
//
// 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
var response: HTTPResponseStatus {
switch self {
2020-09-20 12:36:10 +02:00
/// 404
2020-05-19 15:19:19 +02:00
case .unknownId: return .notFound
2020-09-20 12:36:10 +02:00
/// 400
2020-05-19 15:19:19 +02:00
case .invalidBody: return .badRequest
2020-09-20 12:36:10 +02:00
/// 409
2020-05-19 15:19:19 +02:00
case .dataInconsistency: return .conflict
2020-09-20 12:36:10 +02:00
/// 412
2020-05-19 15:19:19 +02:00
case .invalidFile: return .preconditionFailed
}
}
}