//
//  LKFBatchFileExecutionResult.swift
//  lkfc
//
//  Created by Alexander Holzer on 11.06.18.
//  Copyright © 2018 Alexander Holzer. All rights reserved.
//

import Foundation

public class LKFBatchFileExecutionResult {
    
    var execution: LKFBatchFileExecution
    
    init(execution: LKFBatchFileExecution) {
        self.execution = execution
    }
    
    open func message() -> String? {
        return nil
    }
}

public class LKFBatchFileExecutionResultFailed : LKFBatchFileExecutionResult {
    public let failureText: String
    public let error: Error?
    init (execution: LKFBatchFileExecution, failureText: String) {
        self.error = nil
        self.failureText = failureText
        super.init(execution:execution)
    }
    
    init (execution: LKFBatchFileExecution, error: Error) {
        self.error = error
        self.failureText = error.localizedDescription
        super.init(execution:execution)
    }
    
    var failureTextWithFile : String {
        return "\(failureText) (\(execution.file))"
    }
    
    override open func message() -> String? {
        return failureText
    }
}
