Skip to content

Commit

Permalink
change Error payload to string from Js.Promise.error to string
Browse files Browse the repository at this point in the history
  • Loading branch information
kennetpostigo committed Nov 22, 2017
1 parent 7d109e0 commit 0237825
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/js/src/Regql.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Create(NetworkConfig) {
return Promise.resolve(/* () */0);
})).catch((function (err) {
Curry._2(reduce, (function () {
return /* Error */Block.__(1, [err]);
return /* Error */Block.__(1, ["Regql " + err]);
}), /* () */0);
return Promise.resolve(/* () */0);
}));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "regql",
"version": "0.2.1",
"version": "0.3.0",
"description": "reason graphql",
"main": "index.js",
"author": "Kennet Postigo <[email protected]>",
Expand Down
8 changes: 5 additions & 3 deletions src/Regql.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ module type NetworkConfig = {let uri: string;};

module type ContainerConfig = {type shape; type variables; let decoder: Js.Json.t => shape;};

external errToString : Js.Promise.error => string = "%identity";

module Create = (NetworkConfig: NetworkConfig, ContainerConfig: ContainerConfig) => {
type data = {data: ContainerConfig.shape};
let decoder = (json) : data =>
Json.Decode.{data: json |> field("data", ContainerConfig.decoder)};
type state =
| Loading
| Loaded(ContainerConfig.shape)
| Failed(Js.Promise.error);
| Failed(string);
type action =
| Result(ContainerConfig.shape)
| Error(Js.Promise.error);
| Error(string);
let component = ReasonReact.reducerComponent("Gql");
let make = (~query, ~variables=None, children) => {
...component,
Expand Down Expand Up @@ -65,7 +67,7 @@ module Create = (NetworkConfig: NetworkConfig, ContainerConfig: ContainerConfig)
)
|> catch(
(err) => {
reduce(() => Error(err), ());
reduce(() => Error("Regql " ++ errToString(err)), ());
resolve()
}
)
Expand Down

0 comments on commit 0237825

Please sign in to comment.