-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): change to execute all plugins before throwing on failed (#…
…275) Changed executePlugins() logic to run all plugins, even if one or more plugins have failed. Then console.error the failed plugin errors, and throw. Closes #159
- Loading branch information
1 parent
be60a65
commit 32a6ef5
Showing
9 changed files
with
326 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
isPromiseFulfilledResult, | ||
isPromiseRejectedResult, | ||
} from './promise-result'; | ||
|
||
export function logMultipleResults<T>( | ||
results: PromiseSettledResult<T>[], | ||
messagePrefix: string, | ||
succeededCallback?: (result: PromiseFulfilledResult<T>) => void, | ||
failedCallback?: (result: PromiseRejectedResult) => void, | ||
) { | ||
if (succeededCallback) { | ||
const succeededResults = results.filter(isPromiseFulfilledResult); | ||
|
||
logPromiseResults( | ||
succeededResults, | ||
`${messagePrefix} successfully: `, | ||
succeededCallback, | ||
); | ||
} | ||
|
||
if (failedCallback) { | ||
const failedResults = results.filter(isPromiseRejectedResult); | ||
|
||
logPromiseResults( | ||
failedResults, | ||
`${messagePrefix} failed: `, | ||
failedCallback, | ||
); | ||
} | ||
} | ||
|
||
export function logPromiseResults< | ||
T extends PromiseFulfilledResult<unknown> | PromiseRejectedResult, | ||
>(results: T[], logMessage: string, callback: (result: T) => void): void { | ||
if (results.length) { | ||
console.log(logMessage); | ||
results.forEach(callback); | ||
} | ||
} |
Oops, something went wrong.