This repository was archived by the owner on Nov 9, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +23
-25
lines changed
Expand file tree Collapse file tree 4 files changed +23
-25
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ let createDirectoryTask (ctx: BakeActionContext) script (dir: string) =
1313 if not <| System.IO.Directory.Exists dir then
1414 System.IO.Directory.CreateDirectory dir
1515 |> ignore
16- lock stdout ( fun () -> printfn " CreateDirectory %s " dir)
1716 }
1817
1918[<BakeAction>]
Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ and BakeActionContext = {
2323}
2424
2525module Action =
26- exception MethodIsNotAnException of string
2726 let getActionsFromAssembly ( assembly : Assembly ) =
2827 let toBakeAction ( action : PropertyInfo ) =
2928
@@ -68,7 +67,10 @@ module Action =
6867 , ctx
6968
7069 exception ActionNotFound of string
70+ exception ActionException of Script * BakeActionContext * exn
7171 let runAction ctx script =
7272 match ctx.actions |> Map.tryFind script.command with
7373 | None -> raise <| ActionNotFound script.command
74- | Some action -> action.action ctx script
74+ | Some action ->
75+ try action.action ctx script
76+ with e -> raise <| ActionException ( script, ctx, e)
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ module Task =
2828 else false
2929 with _ -> true
3030
31-
31+ exception TaskException of Task * exn
3232 let run ( task : Task ) : Result < unit , exn > =
3333 if isDirty task then
3434 try
@@ -43,7 +43,7 @@ module Task =
4343 |> Seq.iter ( fun x ->
4444 try System.IO.File.Delete x
4545 with _ -> ())
46- Error e
46+ TaskException ( task , e ) |> Error
4747
4848 else Ok ()
4949
Original file line number Diff line number Diff line change 11
2+ open System
23open Bake
34
5+ let processError fmt =
6+ Console.ForegroundColor <- ConsoleColor.Red
7+ Console.Beep ()
8+ Printf.kprintf ( fun _ -> Console.ResetColor (); - 1 ) fmt
9+
410[<EntryPoint>]
511let main args =
612 try
13+ try
14+ Console.SetWindowSize( 90 , 40 )
15+ with _ -> ()
716 let buildScriptFile =
817 match args with
918 | [||] ->
@@ -58,24 +67,12 @@ let main args =
5867
5968 0
6069 with
61- | Parser.ParsingError e ->
62- printfn " Parsing Error:%s " e
63- - 1
64- | Action.ActionNotFound e ->
65- printfn " Action Not Found:%s " e
66- - 1
67- | Action.ActionUsageError e ->
68- printfn " Action Usage Error:%s " e
69- - 1
70- | e ->
71- printfn " Error:%A " e
72- - 1
73-
74- // Next: 实现以下Action
75- // * If
76- // * Equals $a $b
77- // * Exists File $file
78- // * Exists Directory $dir
79- // * Not $Expression
80- // * $SrcFiles Newer $DstFiles
70+ | Parser.ParsingError e -> processError " Parsing Error:%s " e
71+ | Action.ActionNotFound e -> processError " Action Not Found:%s " e
72+ | Action.ActionUsageError e -> processError " Action Usage Error:%s " e
73+ | Action.ActionException ( script, ctx, e) ->
74+ processError " Action Error:%s \n\n %A \n\n %A \n\n %A " e.Message e script ctx
75+ | Task.TaskException ( task, e) ->
76+ processError " Task Error:%s \n\n %A \n\n %A " e.Message e task
77+ | e -> processError " Error:%A " e
8178
You can’t perform that action at this time.
0 commit comments