Use raw string instead of TerminalText to let user use whichever ansi package they prefer.

This commit is contained in:
Dillon Kearns 2023-01-01 16:53:34 -08:00
parent 7f23779816
commit 4146ed1a11
7 changed files with 21 additions and 29 deletions

File diff suppressed because one or more lines are too long

View File

@ -81,6 +81,7 @@ expect envVariableName =
, TerminalText.yellow envVariableName
, TerminalText.text "` but couldn't find a variable with that name."
]
|> TerminalText.toString
}
)
|> BackendTask.fromResult

View File

@ -300,6 +300,7 @@ jsonFile jsonFileDecoder filePath =
, body =
[ TerminalText.text (Decode.errorToString jsonDecodeError)
]
|> TerminalText.toString
}
)
|> BackendTask.fromResult
@ -339,5 +340,6 @@ errorDecoder filePath =
, TerminalText.yellow filePath
, TerminalText.text "`"
]
|> TerminalText.toString
}
)

View File

@ -411,44 +411,33 @@ requestRaw request__ expect =
)
errorToString : Error -> { title : String, body : List TerminalText.Text }
errorToString : Error -> { title : String, body : String }
errorToString error =
-- TODO turn into formatted build error instead of simple String
case error of
BadUrl string ->
{ title = "HTTP Error"
, body =
{ title = "HTTP Error"
, body =
(case error of
BadUrl string ->
[ TerminalText.text ("BadUrl " ++ string)
]
}
Timeout ->
{ title = "HTTP Error"
, body =
Timeout ->
[ TerminalText.text "Timeout"
]
}
NetworkError ->
{ title = "HTTP Error"
, body =
NetworkError ->
[ TerminalText.text "NetworkError"
]
}
BadStatus _ string ->
{ title = "HTTP Error"
, body =
BadStatus _ string ->
[ TerminalText.text ("BadStatus: " ++ string)
]
}
BadBody string ->
{ title = "HTTP Error"
, body =
BadBody string ->
[ TerminalText.text ("BadBody: " ++ string)
]
}
)
|> TerminalText.toString
}
{-| -}

View File

@ -103,6 +103,7 @@ get portName input decoder =
, body =
[ TerminalText.text "Something went wrong in a call to BackendTask.Port.get."
]
|> TerminalText.toString
}
)
)

View File

@ -6,8 +6,6 @@ module Exception exposing (Throwable, Catchable(..), fromString, fromStringWithV
-}
import TerminalText
{-| -}
type alias Throwable =
@ -16,7 +14,7 @@ type alias Throwable =
{-| -}
type Catchable error
= Catchable error { title : String, body : List TerminalText.Text }
= Catchable error { title : String, body : String }
{-| -}
@ -28,7 +26,7 @@ fromString string =
{-| -}
fromStringWithValue : String -> value -> Catchable value
fromStringWithValue string value =
Catchable value { title = "Custom Error", body = [ TerminalText.text string ] }
Catchable value { title = "Custom Error", body = string }
{-| -}

View File

@ -8,6 +8,7 @@ import List.Extra
import Pages.StaticHttp.Request as HashRequest
import Pages.StaticHttpRequest as StaticHttpRequest
import RequestsAndPending exposing (RequestsAndPending)
import TerminalText
empty : a -> BackendTask Throwable a
@ -141,7 +142,7 @@ nextStep ({ allRawResponses, errors } as model) =
FinishedWithErrors
[ { title = buildError.title |> String.toUpper
, path = "" -- TODO include path here
, message = buildError.body
, message = buildError.body |> TerminalText.fromAnsiString
, fatal = True
}
]