Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Handle errors like they should be handled

dominik-zeglena582062fc96a
diff --git a/saleor/static/dashboard-next/orders/views/OrderDetails/index.tsx b/saleor/static/dashboard-next/orders/views/OrderDetails/index.tsx
index ab222fbbfa..52073a7679 100644
--- a/saleor/static/dashboard-next/orders/views/OrderDetails/index.tsx
+++ b/saleor/static/dashboard-next/orders/views/OrderDetails/index.tsx
@@ -1,7 +1,6 @@
import * as React from "react";
import { Route } from "react-router-dom";
-import ErrorMessageCard from "../../../components/ErrorMessageCard";
import Navigator from "../../../components/Navigator";
import { WindowTitle } from "../../../components/WindowTitle";
import { getMutationState, maybe, transformAddressToForm } from "../../../misc";
@@ -104,9 +103,6 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({
require={["order"]}
>
{({ data, error, loading }) => {
- if (error) {
- return <ErrorMessageCard message="Something went wrong" />;
- }
const order = maybe(() => data.order);
const onModalClose = () => navigate(orderUrl(id), true);
return (
diff --git a/saleor/static/dashboard-next/productTypes/views/ProductTypeList.tsx b/saleor/static/dashboard-next/productTypes/views/ProductTypeList.tsx
index 60e88dbdca..19fe2264e8 100644
--- a/saleor/static/dashboard-next/productTypes/views/ProductTypeList.tsx
+++ b/saleor/static/dashboard-next/productTypes/views/ProductTypeList.tsx
@@ -1,6 +1,5 @@
import * as React from "react";
-import ErrorMessageCard from "../../components/ErrorMessageCard";
import Navigator from "../../components/Navigator";
import { createPaginationState, Paginator } from "../../components/Paginator";
import { maybe } from "../../misc";
@@ -25,32 +24,27 @@ export const ProductTypeList: React.StatelessComponent<
const paginationState = createPaginationState(PAGINATE_BY, params);
return (
<TypedProductTypeListQuery displayLoader variables={paginationState}>
- {({ data, loading, error }) => {
- if (error) {
- return <ErrorMessageCard message="Something went wrong" />;
- }
- return (
- <Paginator
- pageInfo={maybe(() => data.productTypes.pageInfo)}
- paginationState={paginationState}
- queryString={params}
- >
- {({ loadNextPage, loadPreviousPage, pageInfo }) => (
- <ProductTypeListPage
- disabled={loading}
- productTypes={maybe(() =>
- data.productTypes.edges.map(edge => edge.node)
- )}
- pageInfo={pageInfo}
- onAdd={() => navigate(productTypeAddUrl)}
- onNextPage={loadNextPage}
- onPreviousPage={loadPreviousPage}
- onRowClick={id => () => navigate(productTypeUrl(id))}
- />
- )}
- </Paginator>
- );
- }}
+ {({ data, loading }) => (
+ <Paginator
+ pageInfo={maybe(() => data.productTypes.pageInfo)}
+ paginationState={paginationState}
+ queryString={params}
+ >
+ {({ loadNextPage, loadPreviousPage, pageInfo }) => (
+ <ProductTypeListPage
+ disabled={loading}
+ productTypes={maybe(() =>
+ data.productTypes.edges.map(edge => edge.node)
+ )}
+ pageInfo={pageInfo}
+ onAdd={() => navigate(productTypeAddUrl)}
+ onNextPage={loadNextPage}
+ onPreviousPage={loadPreviousPage}
+ onRowClick={id => () => navigate(productTypeUrl(id))}
+ />
+ )}
+ </Paginator>
+ )}
</TypedProductTypeListQuery>
);
}}
diff --git a/saleor/static/dashboard-next/products/views/ProductVariant/index.tsx b/saleor/static/dashboard-next/products/views/ProductVariant/index.tsx
index 49128647ce..fa04e917a8 100644
--- a/saleor/static/dashboard-next/products/views/ProductVariant/index.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductVariant/index.tsx
@@ -2,7 +2,6 @@ import * as React from "react";
import { Route } from "react-router-dom";
import * as placeholderImg from "../../../../images/placeholder255x255.png";
-import ErrorMessageCard from "../../../components/ErrorMessageCard";
import Messages from "../../../components/messages";
import Navigator from "../../../components/Navigator";
import { WindowTitle } from "../../../components/WindowTitle";
@@ -47,9 +46,6 @@ export const ProductVariant: React.StatelessComponent<ProductUpdateProps> = ({
require={["productVariant"]}
>
{({ data, loading, error }) => {
- if (error) {
- return <ErrorMessageCard message="Something went wrong" />;
- }
const variant = data ? data.productVariant : undefined;
const handleBack = () => navigate(productUrl(productId));
const handleDelete = () => {
diff --git a/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx b/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx
index e26dc74534..233203666b 100644
--- a/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductVariantCreate.tsx
@@ -1,6 +1,5 @@
import * as React from "react";
-import ErrorMessageCard from "../../components/ErrorMessageCard";
import Messages from "../../components/messages";
import Navigator from "../../components/Navigator";
import Shop from "../../components/Shop";
@@ -60,14 +59,6 @@ export const ProductVariant: React.StatelessComponent<ProductUpdateProps> = ({
onCompleted={handleCreateSuccess}
>
{(variantCreate, variantCreateResult) => {
- if (variantCreateResult.error) {
- return (
- <ErrorMessageCard
- message={i18n.t("Something went wrong")}
- />
- );
- }
-
const handleBack = () =>
navigate(productUrl(productId));
const handleSubmit = (formData: FormData) =>