Skip to content
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

Add throw function to interrupt pipeline on error #59

Merged
merged 2 commits into from
Oct 6, 2023
Merged
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
Next Next commit
Add throw function to interrupt pipeline on error.
  • Loading branch information
CaptnCodr committed Sep 22, 2023
commit 8b1f5a04e50d445eeb7d4b8e4e24dfb3d7e93dd5
32 changes: 16 additions & 16 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ RESTRICTION: || (== net6.0) (== net7.0) (== netstandard2.0) (== netstandard2.1)
NUGET
remote: https://api.nuget.org/v3/index.json
FSharp.Core (6.0.7)
FsUnit (5.2)
FSharp.Core (>= 6.0.7)
FsUnit (5.4)
FSharp.Core (>= 5.0.2)
NUnit (>= 3.13.3 < 3.14)
Microsoft.CodeCoverage (17.4.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= net462)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Microsoft.NET.Test.Sdk (17.4.1)
Microsoft.CodeCoverage (>= 17.4.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= net462)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Microsoft.TestPlatform.TestHost (>= 17.4.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Microsoft.NETCore.Platforms (7.0)
Microsoft.TestPlatform.ObjectModel (17.4.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
NuGet.Frameworks (>= 5.11)
Microsoft.CodeCoverage (17.7.2) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= net462)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Microsoft.NET.Test.Sdk (17.7.2)
Microsoft.CodeCoverage (>= 17.7.2) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net462)) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= net462)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Microsoft.TestPlatform.TestHost (>= 17.7.2) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Microsoft.NETCore.Platforms (7.0.4)
Microsoft.TestPlatform.ObjectModel (17.7.2) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
NuGet.Frameworks (>= 6.5)
System.Reflection.Metadata (>= 1.6)
Microsoft.TestPlatform.TestHost (17.4.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Microsoft.TestPlatform.ObjectModel (>= 17.4.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Microsoft.TestPlatform.TestHost (17.7.2) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Microsoft.TestPlatform.ObjectModel (>= 17.7.2) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Newtonsoft.Json (>= 13.0.1) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
NETStandard.Library (2.0.3)
Microsoft.NETCore.Platforms (>= 1.1)
Newtonsoft.Json (13.0.2) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
NuGet.Frameworks (6.4) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
Newtonsoft.Json (13.0.3) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
NuGet.Frameworks (6.7) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
NUnit (3.13.3)
NETStandard.Library (>= 2.0)
NUnit.Analyzers (3.5)
NUnit3TestAdapter (4.3.1)
NUnit.Analyzers (3.7)
NUnit3TestAdapter (4.5)
System.Collections.Immutable (7.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (== net6.0) (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0) (== netstandard2.1)
System.Reflection.Metadata (7.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
System.Reflection.Metadata (7.0.2) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
System.Collections.Immutable (>= 7.0)
System.Runtime.CompilerServices.Unsafe (6.0) - restriction: || (== net6.0) (&& (== net7.0) (== netstandard2.0)) (&& (== net7.0) (== netstandard2.1)) (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= net6.0)) (&& (== netstandard2.1) (>= netcoreapp3.1))
10 changes: 10 additions & 0 deletions src/Fli/Output.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ module Output =

/// Prints `Error` from `Output`.
let printError = toError >> printfn "%s"

/// Throws exception if given condition in `func` matches.
let throw (func: Output -> bool) (output: Output) =
if output |> func then
failwith $"Execution failed with exit code {output.ExitCode} {output.Error}"

output

/// Throws exception if exit code is not 0.
let throwIfErrored = throw (fun o -> o.ExitCode <> 0)