Skip to content

Pass errorcode incase of error on completion of task #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Forge/Classes/ChangeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ public protocol ChangeManager: class {

func willStart(task: Task)

func didComplete(task: Task, result: Result<Any, ExecutorError>)
func didComplete(task: Task, result: Result<Any, ExecutorError>, errorCode: String?)
}
8 changes: 4 additions & 4 deletions Forge/Classes/ExecutionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class ExecutionManager {
switch result {
case .success(_):
strongSelf.executionDelegate?.delete(pTask: pTask)
strongSelf.changeManager?.didComplete(task: pTask.task, result: result)
strongSelf.changeManager?.didComplete(task: pTask.task, result: result, errorCode: nil)
case .failure(let error):
switch error {
case .NonRetriable:
case .NonRetriable(let errorCode):
strongSelf.executionDelegate?.delete(pTask: pTask)
strongSelf.changeManager?.didComplete(task: pTask.task, result: result)
strongSelf.changeManager?.didComplete(task: pTask.task, result: result, errorCode: errorCode)
case .ConditionalRetriable:
strongSelf.executionDelegate?.fail(pTask: pTask, increaseRetryCount: false)
return
Expand All @@ -55,7 +55,7 @@ class ExecutionManager {
}

func undoChangeManagerAction(pTask: PersistentTask) {
changeManager?.didComplete(task: pTask.task, result: Result.failure(ExecutorError.Cancelled))
changeManager?.didComplete(task: pTask.task, result: Result.failure(ExecutorError.Cancelled), errorCode: nil)
}

/// Just like @p execute, but doesn't assert on executor's presence.
Expand Down
2 changes: 1 addition & 1 deletion Forge/Classes/ExecutorError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Foundation

public enum ExecutorError: Error {
case NonRetriable
case NonRetriable(_ errorCode: String?)
case ConditionalRetriable
case NonConditionalRetriable
case Cancelled
Expand Down