//
//  LKFError.swift
//  lkfc
//
//  Created by Alexander Holzer on 07.06.18.
//  Copyright © 2018 Alexander Holzer. All rights reserved.
//

import Foundation

public class LKFError : LocalizedError {
    
    public let message: String
    public let error : Error?
    
    public init (message: String) {
        self.message = message
        self.error = nil
    }
    
    static public func from (error: Error) -> LKFError {
        if let lkfError = error as? LKFError {
            return lkfError
        }
        return LKFError(error: error)
    }
    
    public convenience init (_ msg: String) {
        self.init(message: msg)
    }
    
    public var errorDescription: String? {
        return message
    }
    
    public var localizedDescription: String {
        get {
            return error?.localizedDescription ?? message
        }
    }
    
    public init (error: Error) {
        self.message = error.localizedDescription
        self.error = error
    }
}

public class LKFOutOfMemoryError : LKFError {
    
}

public class LKFPlausCheckError : LKFError {
    
}

public class LKFScoringError: LKFError {
    
}
