mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 04:43:03 +03:00
Rename Exception.Catchable -> Exception.Exception to reduce number of terms.
This commit is contained in:
parent
d68f943967
commit
e5bcdf2d6e
@ -2,7 +2,7 @@ module Route.Showcase exposing (ActionData, Data, Model, Msg, route)
|
|||||||
|
|
||||||
import BackendTask exposing (BackendTask)
|
import BackendTask exposing (BackendTask)
|
||||||
import Css
|
import Css
|
||||||
import Exception exposing (Catchable, Throwable)
|
import Exception exposing (Exception, Throwable)
|
||||||
import Head
|
import Head
|
||||||
import Head.Seo as Seo
|
import Head.Seo as Seo
|
||||||
import Html.Styled exposing (..)
|
import Html.Styled exposing (..)
|
||||||
|
@ -5,7 +5,7 @@ import BackendTask.File as File
|
|||||||
import BackendTask.Glob as Glob
|
import BackendTask.Glob as Glob
|
||||||
import Cloudinary
|
import Cloudinary
|
||||||
import Date exposing (Date)
|
import Date exposing (Date)
|
||||||
import Exception exposing (Catchable, Throwable)
|
import Exception exposing (Exception, Throwable)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
import Pages.Url exposing (Url)
|
import Pages.Url exposing (Url)
|
||||||
import Route
|
import Route
|
||||||
@ -27,7 +27,7 @@ blogPostsGlob =
|
|||||||
|> Glob.toBackendTask
|
|> Glob.toBackendTask
|
||||||
|
|
||||||
|
|
||||||
allMetadata : BackendTask.BackendTask (Catchable (File.FileReadError Decode.Error)) (List ( Route.Route, ArticleMetadata ))
|
allMetadata : BackendTask.BackendTask (Exception (File.FileReadError Decode.Error)) (List ( Route.Route, ArticleMetadata ))
|
||||||
allMetadata =
|
allMetadata =
|
||||||
blogPostsGlob
|
blogPostsGlob
|
||||||
|> BackendTask.map
|
|> BackendTask.map
|
||||||
|
@ -2,7 +2,7 @@ module Test.HttpRequests exposing (all)
|
|||||||
|
|
||||||
import BackendTask exposing (BackendTask)
|
import BackendTask exposing (BackendTask)
|
||||||
import BackendTask.Http
|
import BackendTask.Http
|
||||||
import Exception exposing (Catchable)
|
import Exception exposing (Exception)
|
||||||
import Expect
|
import Expect
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import Test exposing (Test)
|
import Test exposing (Test)
|
||||||
@ -112,7 +112,7 @@ all =
|
|||||||
|> BackendTask.map (Test.describe "BackendTask tests")
|
|> BackendTask.map (Test.describe "BackendTask tests")
|
||||||
|
|
||||||
|
|
||||||
test : String -> (Result error data -> Expect.Expectation) -> BackendTask (Catchable error) data -> BackendTask noError Test
|
test : String -> (Result error data -> Expect.Expectation) -> BackendTask (Exception error) data -> BackendTask noError Test
|
||||||
test name assert task =
|
test name assert task =
|
||||||
task
|
task
|
||||||
|> BackendTask.toResult
|
|> BackendTask.toResult
|
||||||
|
@ -76,7 +76,7 @@ data { pokedexNumber } =
|
|||||||
|> BackendTask.map Response.render
|
|> BackendTask.map Response.render
|
||||||
|
|
||||||
|
|
||||||
get : String -> Decode.Decoder value -> BackendTask (Exception.Catchable BackendTask.Http.Error) value
|
get : String -> Decode.Decoder value -> BackendTask (Exception.Exception BackendTask.Http.Error) value
|
||||||
get url decoder =
|
get url decoder =
|
||||||
BackendTask.Http.getWithOptions
|
BackendTask.Http.getWithOptions
|
||||||
{ url = url
|
{ url = url
|
||||||
|
@ -86,7 +86,7 @@ Any place in your `elm-pages` app where the framework lets you pass in a value o
|
|||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Exception exposing (Catchable(..), Throwable)
|
import Exception exposing (Exception(..), Throwable)
|
||||||
import Json.Encode
|
import Json.Encode
|
||||||
import Pages.StaticHttpRequest exposing (RawRequest(..))
|
import Pages.StaticHttpRequest exposing (RawRequest(..))
|
||||||
|
|
||||||
@ -524,26 +524,26 @@ map9 combineFn request1 request2 request3 request4 request5 request6 request7 re
|
|||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
catch : BackendTask (Catchable error) value -> BackendTask error value
|
catch : BackendTask (Exception error) value -> BackendTask error value
|
||||||
catch ds =
|
catch ds =
|
||||||
ds
|
ds
|
||||||
|> onError
|
|> onError
|
||||||
(\exception ->
|
(\exception ->
|
||||||
case exception of
|
case exception of
|
||||||
Catchable error _ ->
|
Exception error _ ->
|
||||||
fail error
|
fail error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
throw : BackendTask (Catchable error) data -> BackendTask Throwable data
|
throw : BackendTask (Exception error) data -> BackendTask Throwable data
|
||||||
throw backendTask =
|
throw backendTask =
|
||||||
backendTask
|
backendTask
|
||||||
|> onError (Exception.throw >> fail)
|
|> onError (Exception.throw >> fail)
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
toResult : BackendTask (Catchable error) data -> BackendTask noError (Result error data)
|
toResult : BackendTask (Exception error) data -> BackendTask noError (Result error data)
|
||||||
toResult backendTask =
|
toResult backendTask =
|
||||||
backendTask
|
backendTask
|
||||||
|> catch
|
|> catch
|
||||||
|
@ -39,7 +39,7 @@ down into the final `Data` value, it won't end up in the client!
|
|||||||
import BackendTask exposing (BackendTask)
|
import BackendTask exposing (BackendTask)
|
||||||
import BackendTask.Http
|
import BackendTask.Http
|
||||||
import BackendTask.Internal.Request
|
import BackendTask.Internal.Request
|
||||||
import Exception exposing (Catchable)
|
import Exception exposing (Exception)
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
import TerminalText
|
import TerminalText
|
||||||
@ -65,7 +65,7 @@ get envVariableName =
|
|||||||
|
|
||||||
{-| Get an environment variable, or a BackendTask failure if there is no environment variable matching that name.
|
{-| Get an environment variable, or a BackendTask failure if there is no environment variable matching that name.
|
||||||
-}
|
-}
|
||||||
expect : String -> BackendTask (Catchable Error) String
|
expect : String -> BackendTask (Exception Error) String
|
||||||
expect envVariableName =
|
expect envVariableName =
|
||||||
envVariableName
|
envVariableName
|
||||||
|> get
|
|> get
|
||||||
@ -73,7 +73,7 @@ expect envVariableName =
|
|||||||
(\maybeValue ->
|
(\maybeValue ->
|
||||||
maybeValue
|
maybeValue
|
||||||
|> Result.fromMaybe
|
|> Result.fromMaybe
|
||||||
(Exception.Catchable (MissingEnvVariable envVariableName)
|
(Exception.Exception (MissingEnvVariable envVariableName)
|
||||||
{ title = "Missing Env Variable"
|
{ title = "Missing Env Variable"
|
||||||
, body =
|
, body =
|
||||||
[ TerminalText.text "BackendTask.Env.expect was expecting a variable `"
|
[ TerminalText.text "BackendTask.Env.expect was expecting a variable `"
|
||||||
|
@ -51,7 +51,7 @@ plain old JSON in Elm.
|
|||||||
import BackendTask exposing (BackendTask)
|
import BackendTask exposing (BackendTask)
|
||||||
import BackendTask.Http
|
import BackendTask.Http
|
||||||
import BackendTask.Internal.Request
|
import BackendTask.Internal.Request
|
||||||
import Exception exposing (Catchable)
|
import Exception exposing (Exception)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
import TerminalText
|
import TerminalText
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ It's common to parse the body with a markdown parser or other format.
|
|||||||
)
|
)
|
||||||
|
|
||||||
-}
|
-}
|
||||||
bodyWithFrontmatter : (String -> Decoder frontmatter) -> String -> BackendTask (Catchable (FileReadError Decode.Error)) frontmatter
|
bodyWithFrontmatter : (String -> Decoder frontmatter) -> String -> BackendTask (Exception (FileReadError Decode.Error)) frontmatter
|
||||||
bodyWithFrontmatter frontmatterDecoder filePath =
|
bodyWithFrontmatter frontmatterDecoder filePath =
|
||||||
read filePath
|
read filePath
|
||||||
(body
|
(body
|
||||||
@ -213,7 +213,7 @@ the [`BackendTask`](BackendTask) API along with [`BackendTask.Glob`](BackendTask
|
|||||||
|> BackendTask.resolve
|
|> BackendTask.resolve
|
||||||
|
|
||||||
-}
|
-}
|
||||||
onlyFrontmatter : Decoder frontmatter -> String -> BackendTask (Catchable (FileReadError Decode.Error)) frontmatter
|
onlyFrontmatter : Decoder frontmatter -> String -> BackendTask (Exception (FileReadError Decode.Error)) frontmatter
|
||||||
onlyFrontmatter frontmatterDecoder filePath =
|
onlyFrontmatter frontmatterDecoder filePath =
|
||||||
read filePath
|
read filePath
|
||||||
(frontmatter frontmatterDecoder)
|
(frontmatter frontmatterDecoder)
|
||||||
@ -240,7 +240,7 @@ Hey there! This is my first post :)
|
|||||||
Then data will yield the value `"Hey there! This is my first post :)"`.
|
Then data will yield the value `"Hey there! This is my first post :)"`.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
bodyWithoutFrontmatter : String -> BackendTask (Catchable (FileReadError decoderError)) String
|
bodyWithoutFrontmatter : String -> BackendTask (Exception (FileReadError decoderError)) String
|
||||||
bodyWithoutFrontmatter filePath =
|
bodyWithoutFrontmatter filePath =
|
||||||
read filePath
|
read filePath
|
||||||
body
|
body
|
||||||
@ -264,7 +264,7 @@ You could read a file called `hello.txt` in your root project directory like thi
|
|||||||
File.rawFile "hello.txt"
|
File.rawFile "hello.txt"
|
||||||
|
|
||||||
-}
|
-}
|
||||||
rawFile : String -> BackendTask (Catchable (FileReadError decoderError)) String
|
rawFile : String -> BackendTask (Exception (FileReadError decoderError)) String
|
||||||
rawFile filePath =
|
rawFile filePath =
|
||||||
read filePath (Decode.field "rawFile" Decode.string)
|
read filePath (Decode.field "rawFile" Decode.string)
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ The Decode will strip off any unused JSON data.
|
|||||||
"elm.json"
|
"elm.json"
|
||||||
|
|
||||||
-}
|
-}
|
||||||
jsonFile : Decoder a -> String -> BackendTask (Catchable (FileReadError Decode.Error)) a
|
jsonFile : Decoder a -> String -> BackendTask (Exception (FileReadError Decode.Error)) a
|
||||||
jsonFile jsonFileDecoder filePath =
|
jsonFile jsonFileDecoder filePath =
|
||||||
rawFile filePath
|
rawFile filePath
|
||||||
|> BackendTask.andThen
|
|> BackendTask.andThen
|
||||||
@ -295,7 +295,7 @@ jsonFile jsonFileDecoder filePath =
|
|||||||
|> Decode.decodeString jsonFileDecoder
|
|> Decode.decodeString jsonFileDecoder
|
||||||
|> Result.mapError
|
|> Result.mapError
|
||||||
(\jsonDecodeError ->
|
(\jsonDecodeError ->
|
||||||
Exception.Catchable (DecodingError jsonDecodeError)
|
Exception.Exception (DecodingError jsonDecodeError)
|
||||||
{ title = "JSON Decoding Error"
|
{ title = "JSON Decoding Error"
|
||||||
, body =
|
, body =
|
||||||
[ TerminalText.text (Decode.errorToString jsonDecodeError)
|
[ TerminalText.text (Decode.errorToString jsonDecodeError)
|
||||||
@ -314,7 +314,7 @@ body =
|
|||||||
Decode.field "withoutFrontmatter" Decode.string
|
Decode.field "withoutFrontmatter" Decode.string
|
||||||
|
|
||||||
|
|
||||||
read : String -> Decoder a -> BackendTask (Catchable (FileReadError error)) a
|
read : String -> Decoder a -> BackendTask (Exception (FileReadError error)) a
|
||||||
read filePath decoder =
|
read filePath decoder =
|
||||||
BackendTask.Internal.Request.request
|
BackendTask.Internal.Request.request
|
||||||
{ name = "read-file"
|
{ name = "read-file"
|
||||||
@ -330,10 +330,10 @@ read filePath decoder =
|
|||||||
|> BackendTask.andThen BackendTask.fromResult
|
|> BackendTask.andThen BackendTask.fromResult
|
||||||
|
|
||||||
|
|
||||||
errorDecoder : String -> Decoder (Catchable (FileReadError decoding))
|
errorDecoder : String -> Decoder (Exception (FileReadError decoding))
|
||||||
errorDecoder filePath =
|
errorDecoder filePath =
|
||||||
Decode.succeed
|
Decode.succeed
|
||||||
(Exception.Catchable FileDoesntExist
|
(Exception.Exception FileDoesntExist
|
||||||
{ title = "File Doesn't Exist"
|
{ title = "File Doesn't Exist"
|
||||||
, body =
|
, body =
|
||||||
[ TerminalText.text "Couldn't find file at path `"
|
[ TerminalText.text "Couldn't find file at path `"
|
||||||
|
@ -229,7 +229,7 @@ import BackendTask exposing (BackendTask)
|
|||||||
import BackendTask.Http
|
import BackendTask.Http
|
||||||
import BackendTask.Internal.Glob exposing (Glob(..))
|
import BackendTask.Internal.Glob exposing (Glob(..))
|
||||||
import BackendTask.Internal.Request
|
import BackendTask.Internal.Request
|
||||||
import Exception exposing (Catchable, Throwable)
|
import Exception exposing (Exception, Throwable)
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
import List.Extra
|
import List.Extra
|
||||||
@ -1054,7 +1054,7 @@ so it's ideal to make this kind of assertion rather than having fallback behavio
|
|||||||
issues (like if we had instead ignored the case where there are two or more matching blog post files).
|
issues (like if we had instead ignored the case where there are two or more matching blog post files).
|
||||||
|
|
||||||
-}
|
-}
|
||||||
expectUniqueMatch : Glob a -> BackendTask (Catchable String) a
|
expectUniqueMatch : Glob a -> BackendTask (Exception String) a
|
||||||
expectUniqueMatch glob =
|
expectUniqueMatch glob =
|
||||||
glob
|
glob
|
||||||
|> toBackendTask
|
|> toBackendTask
|
||||||
|
@ -104,7 +104,7 @@ import Base64
|
|||||||
import Bytes exposing (Bytes)
|
import Bytes exposing (Bytes)
|
||||||
import Bytes.Decode
|
import Bytes.Decode
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Exception exposing (Catchable)
|
import Exception exposing (Exception)
|
||||||
import Json.Decode
|
import Json.Decode
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
import Pages.Internal.StaticHttpBody as Body
|
import Pages.Internal.StaticHttpBody as Body
|
||||||
@ -157,10 +157,10 @@ type alias Body =
|
|||||||
|
|
||||||
import BackendTask
|
import BackendTask
|
||||||
import BackendTask.Http
|
import BackendTask.Http
|
||||||
import Exception exposing (Catchable)
|
import Exception exposing (Exception)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
|
|
||||||
getRequest : BackendTask (Catchable Error) Int
|
getRequest : BackendTask (Exception Error) Int
|
||||||
getRequest =
|
getRequest =
|
||||||
BackendTask.Http.getJson
|
BackendTask.Http.getJson
|
||||||
"https://api.github.com/repos/dillonkearns/elm-pages"
|
"https://api.github.com/repos/dillonkearns/elm-pages"
|
||||||
@ -170,7 +170,7 @@ type alias Body =
|
|||||||
getJson :
|
getJson :
|
||||||
String
|
String
|
||||||
-> Json.Decode.Decoder a
|
-> Json.Decode.Decoder a
|
||||||
-> BackendTask (Catchable Error) a
|
-> BackendTask (Exception Error) a
|
||||||
getJson url decoder =
|
getJson url decoder =
|
||||||
getWithOptions
|
getWithOptions
|
||||||
{ url = url
|
{ url = url
|
||||||
@ -189,9 +189,9 @@ use the more flexible `getWithOptions`.
|
|||||||
|
|
||||||
import BackendTask
|
import BackendTask
|
||||||
import BackendTask.Http
|
import BackendTask.Http
|
||||||
import Exception exposing (Catchable)
|
import Exception exposing (Exception)
|
||||||
|
|
||||||
getRequest : BackendTask (Catchable Error) String
|
getRequest : BackendTask (Exception Error) String
|
||||||
getRequest =
|
getRequest =
|
||||||
BackendTask.Http.get
|
BackendTask.Http.get
|
||||||
"https://api.github.com/repos/dillonkearns/elm-pages"
|
"https://api.github.com/repos/dillonkearns/elm-pages"
|
||||||
@ -201,7 +201,7 @@ use the more flexible `getWithOptions`.
|
|||||||
get :
|
get :
|
||||||
String
|
String
|
||||||
-> Expect a
|
-> Expect a
|
||||||
-> BackendTask (Catchable Error) a
|
-> BackendTask (Exception Error) a
|
||||||
get url expect =
|
get url expect =
|
||||||
getWithOptions
|
getWithOptions
|
||||||
{ url = url
|
{ url = url
|
||||||
@ -231,7 +231,7 @@ getWithOptions :
|
|||||||
, timeoutInMs : Maybe Int
|
, timeoutInMs : Maybe Int
|
||||||
, cachePath : Maybe String
|
, cachePath : Maybe String
|
||||||
}
|
}
|
||||||
-> BackendTask (Catchable Error) a
|
-> BackendTask (Exception Error) a
|
||||||
getWithOptions request__ =
|
getWithOptions request__ =
|
||||||
let
|
let
|
||||||
request_ : HashRequest.Request
|
request_ : HashRequest.Request
|
||||||
@ -258,7 +258,7 @@ post :
|
|||||||
String
|
String
|
||||||
-> Body
|
-> Body
|
||||||
-> Expect a
|
-> Expect a
|
||||||
-> BackendTask (Catchable Error) a
|
-> BackendTask (Exception Error) a
|
||||||
post url body expect =
|
post url body expect =
|
||||||
request
|
request
|
||||||
{ url = url
|
{ url = url
|
||||||
@ -397,7 +397,7 @@ request :
|
|||||||
, timeoutInMs : Maybe Int
|
, timeoutInMs : Maybe Int
|
||||||
}
|
}
|
||||||
-> Expect a
|
-> Expect a
|
||||||
-> BackendTask (Catchable Error) a
|
-> BackendTask (Exception Error) a
|
||||||
request request__ expect =
|
request request__ expect =
|
||||||
let
|
let
|
||||||
request_ : HashRequest.Request
|
request_ : HashRequest.Request
|
||||||
@ -475,7 +475,7 @@ with this as a low-level detail, or you can use functions like [BackendTask.Http
|
|||||||
requestRaw :
|
requestRaw :
|
||||||
HashRequest.Request
|
HashRequest.Request
|
||||||
-> Expect a
|
-> Expect a
|
||||||
-> BackendTask (Catchable Error) a
|
-> BackendTask (Exception Error) a
|
||||||
requestRaw request__ expect =
|
requestRaw request__ expect =
|
||||||
let
|
let
|
||||||
request_ : HashRequest.Request
|
request_ : HashRequest.Request
|
||||||
@ -573,7 +573,7 @@ requestRaw request__ expect =
|
|||||||
|> BackendTask.fromResult
|
|> BackendTask.fromResult
|
||||||
|> BackendTask.mapError
|
|> BackendTask.mapError
|
||||||
(\error ->
|
(\error ->
|
||||||
Exception.Catchable error (errorToString error)
|
Exception.Exception error (errorToString error)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ module BackendTask.Port exposing
|
|||||||
import BackendTask
|
import BackendTask
|
||||||
import BackendTask.Http
|
import BackendTask.Http
|
||||||
import BackendTask.Internal.Request
|
import BackendTask.Internal.Request
|
||||||
import Exception exposing (Catchable)
|
import Exception exposing (Exception)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
import TerminalText
|
import TerminalText
|
||||||
@ -81,7 +81,7 @@ prefer to add ANSI color codes within the error string in an exception and it wi
|
|||||||
As with any JavaScript or NodeJS code, avoid doing blocking IO operations. For example, avoid using `fs.readFileSync`, because blocking IO can slow down your elm-pages builds and dev server.
|
As with any JavaScript or NodeJS code, avoid doing blocking IO operations. For example, avoid using `fs.readFileSync`, because blocking IO can slow down your elm-pages builds and dev server.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
get : String -> Encode.Value -> Decoder b -> BackendTask.BackendTask (Catchable Error) b
|
get : String -> Encode.Value -> Decoder b -> BackendTask.BackendTask (Exception Error) b
|
||||||
get portName input decoder =
|
get portName input decoder =
|
||||||
BackendTask.Internal.Request.request
|
BackendTask.Internal.Request.request
|
||||||
{ name = "port"
|
{ name = "port"
|
||||||
@ -97,7 +97,7 @@ get portName input decoder =
|
|||||||
|> Decode.andThen
|
|> Decode.andThen
|
||||||
(\errorKind ->
|
(\errorKind ->
|
||||||
if errorKind == "PortNotDefined" then
|
if errorKind == "PortNotDefined" then
|
||||||
Exception.Catchable (PortNotDefined { name = portName })
|
Exception.Exception (PortNotDefined { name = portName })
|
||||||
{ title = "Port Error"
|
{ title = "Port Error"
|
||||||
, body =
|
, body =
|
||||||
[ TerminalText.text "Something went wrong in a call to BackendTask.Port.get. I expected to find a port named `"
|
[ TerminalText.text "Something went wrong in a call to BackendTask.Port.get. I expected to find a port named `"
|
||||||
@ -114,7 +114,7 @@ get portName input decoder =
|
|||||||
|> Decode.map (Maybe.withDefault "")
|
|> Decode.map (Maybe.withDefault "")
|
||||||
|> Decode.map
|
|> Decode.map
|
||||||
(\incorrectPortType ->
|
(\incorrectPortType ->
|
||||||
Exception.Catchable ExportIsNotFunction
|
Exception.Exception ExportIsNotFunction
|
||||||
{ title = "Port Error"
|
{ title = "Port Error"
|
||||||
, body =
|
, body =
|
||||||
[ TerminalText.text "Something went wrong in a call to BackendTask.Port.get. I found an export called `"
|
[ TerminalText.text "Something went wrong in a call to BackendTask.Port.get. I found an export called `"
|
||||||
@ -127,7 +127,7 @@ get portName input decoder =
|
|||||||
)
|
)
|
||||||
|
|
||||||
else if errorKind == "MissingPortsFile" then
|
else if errorKind == "MissingPortsFile" then
|
||||||
Exception.Catchable MissingPortsFile
|
Exception.Exception MissingPortsFile
|
||||||
{ title = "Port Error"
|
{ title = "Port Error"
|
||||||
, body =
|
, body =
|
||||||
[ TerminalText.text "Something went wrong in a call to BackendTask.Port.get. I couldn't find your port-data-source file. Be sure to create a 'port-data-source.ts' or 'port-data-source.js' file."
|
[ TerminalText.text "Something went wrong in a call to BackendTask.Port.get. I couldn't find your port-data-source file. Be sure to create a 'port-data-source.ts' or 'port-data-source.js' file."
|
||||||
@ -142,7 +142,7 @@ get portName input decoder =
|
|||||||
|> Decode.map (Maybe.withDefault "")
|
|> Decode.map (Maybe.withDefault "")
|
||||||
|> Decode.map
|
|> Decode.map
|
||||||
(\errorMessage ->
|
(\errorMessage ->
|
||||||
Exception.Catchable
|
Exception.Exception
|
||||||
ErrorInPortsFile
|
ErrorInPortsFile
|
||||||
{ title = "Port Error"
|
{ title = "Port Error"
|
||||||
, body =
|
, body =
|
||||||
@ -160,7 +160,7 @@ get portName input decoder =
|
|||||||
|> Decode.map (Maybe.withDefault Encode.null)
|
|> Decode.map (Maybe.withDefault Encode.null)
|
||||||
|> Decode.map
|
|> Decode.map
|
||||||
(\portCallError ->
|
(\portCallError ->
|
||||||
Exception.Catchable
|
Exception.Exception
|
||||||
(PortCallError portCallError)
|
(PortCallError portCallError)
|
||||||
{ title = "Port Error"
|
{ title = "Port Error"
|
||||||
, body =
|
, body =
|
||||||
@ -173,7 +173,7 @@ get portName input decoder =
|
|||||||
)
|
)
|
||||||
|
|
||||||
else
|
else
|
||||||
Exception.Catchable ErrorInPortsFile
|
Exception.Exception ErrorInPortsFile
|
||||||
{ title = "Port Error"
|
{ title = "Port Error"
|
||||||
, body =
|
, body =
|
||||||
[ TerminalText.text "Something went wrong in a call to BackendTask.Port.get. I expected to find a port named `"
|
[ TerminalText.text "Something went wrong in a call to BackendTask.Port.get. I expected to find a port named `"
|
||||||
|
@ -1,37 +1,37 @@
|
|||||||
module Exception exposing (Throwable, Catchable(..), fromString, fromStringWithValue, throw)
|
module Exception exposing (Throwable, Exception(..), fromString, fromStringWithValue, throw)
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
|
|
||||||
@docs Throwable, Catchable, fromString, fromStringWithValue, throw
|
@docs Throwable, Exception, fromString, fromStringWithValue, throw
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
type alias Throwable =
|
type alias Throwable =
|
||||||
Catchable ()
|
Exception ()
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
type Catchable error
|
type Exception error
|
||||||
= Catchable error { title : String, body : String }
|
= Exception error { title : String, body : String }
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
fromString : String -> Catchable ()
|
fromString : String -> Exception ()
|
||||||
fromString string =
|
fromString string =
|
||||||
fromStringWithValue string ()
|
fromStringWithValue string ()
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
fromStringWithValue : String -> value -> Catchable value
|
fromStringWithValue : String -> value -> Exception value
|
||||||
fromStringWithValue string value =
|
fromStringWithValue string value =
|
||||||
Catchable value { title = "Custom Error", body = string }
|
Exception value { title = "Custom Error", body = string }
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
throw : Catchable error -> Catchable ()
|
throw : Exception error -> Exception ()
|
||||||
throw exception =
|
throw exception =
|
||||||
case exception of
|
case exception of
|
||||||
Catchable _ string ->
|
Exception _ string ->
|
||||||
Catchable () string
|
Exception () string
|
||||||
|
@ -2,7 +2,7 @@ module Pages.Internal.Platform.StaticResponses exposing (NextStep(..), batchUpda
|
|||||||
|
|
||||||
import BackendTask exposing (BackendTask)
|
import BackendTask exposing (BackendTask)
|
||||||
import BuildError exposing (BuildError)
|
import BuildError exposing (BuildError)
|
||||||
import Exception exposing (Catchable(..), Throwable)
|
import Exception exposing (Exception(..), Throwable)
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import List.Extra
|
import List.Extra
|
||||||
import Pages.StaticHttp.Request as HashRequest
|
import Pages.StaticHttp.Request as HashRequest
|
||||||
@ -125,7 +125,7 @@ nextStep ({ allRawResponses, errors } as model) =
|
|||||||
Just (Ok completed) ->
|
Just (Ok completed) ->
|
||||||
Finish completed
|
Finish completed
|
||||||
|
|
||||||
Just (Err (Catchable () buildError)) ->
|
Just (Err (Exception () buildError)) ->
|
||||||
FinishedWithErrors
|
FinishedWithErrors
|
||||||
[ { title = buildError.title |> String.toUpper
|
[ { title = buildError.title |> String.toUpper
|
||||||
, path = "" -- TODO include path here
|
, path = "" -- TODO include path here
|
||||||
|
@ -34,7 +34,7 @@ import BackendTask.Http
|
|||||||
import BackendTask.Internal.Request
|
import BackendTask.Internal.Request
|
||||||
import Cli.OptionsParser as OptionsParser
|
import Cli.OptionsParser as OptionsParser
|
||||||
import Cli.Program as Program
|
import Cli.Program as Program
|
||||||
import Exception exposing (Catchable, Throwable)
|
import Exception exposing (Exception, Throwable)
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
import Pages.Internal.Script
|
import Pages.Internal.Script
|
||||||
@ -52,7 +52,7 @@ type Error
|
|||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
writeFile : { path : String, body : String } -> BackendTask (Catchable Error) ()
|
writeFile : { path : String, body : String } -> BackendTask (Exception Error) ()
|
||||||
writeFile { path, body } =
|
writeFile { path, body } =
|
||||||
BackendTask.Internal.Request.request
|
BackendTask.Internal.Request.request
|
||||||
{ name = "write-file"
|
{ name = "write-file"
|
||||||
|
Loading…
Reference in New Issue
Block a user