show error hint if its found
This commit is contained in:
parent
505eb07d8e
commit
ce3ffbcd81
@ -13,7 +13,7 @@
|
|||||||
You should have received a copy of the GNU General Public License along with
|
You should have received a copy of the GNU General Public License along with
|
||||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
import { TalerErrorDetails } from "@gnu-taler/taler-util";
|
import { TalerErrorCode, TalerErrorDetails } from "@gnu-taler/taler-util";
|
||||||
import { VNode, h, Fragment } from "preact";
|
import { VNode, h, Fragment } from "preact";
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
import arrowDown from "../../static/img/chevron-down.svg";
|
import arrowDown from "../../static/img/chevron-down.svg";
|
||||||
@ -29,7 +29,11 @@ export function ErrorTalerOperation({
|
|||||||
}): VNode | null {
|
}): VNode | null {
|
||||||
const { devMode } = useDevContext();
|
const { devMode } = useDevContext();
|
||||||
const [showErrorDetail, setShowErrorDetail] = useState(false);
|
const [showErrorDetail, setShowErrorDetail] = useState(false);
|
||||||
|
|
||||||
if (!title || !error) return null;
|
if (!title || !error) return null;
|
||||||
|
// const errorCode: number | undefined = (error.details as any)?.errorResponse?.code
|
||||||
|
const errorHint: string | undefined = (error.details as any)?.errorResponse?.hint
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBox style={{ paddingTop: 0, paddingBottom: 0 }}>
|
<ErrorBox style={{ paddingTop: 0, paddingBottom: 0 }}>
|
||||||
<div>
|
<div>
|
||||||
@ -49,6 +53,11 @@ export function ErrorTalerOperation({
|
|||||||
<div style={{ padding: 5, textAlign: "left" }}>
|
<div style={{ padding: 5, textAlign: "left" }}>
|
||||||
<div>{error.message}</div>
|
<div>{error.message}</div>
|
||||||
</div>
|
</div>
|
||||||
|
{errorHint &&
|
||||||
|
<div style={{ padding: 5, textAlign: "left" }}>
|
||||||
|
<div>{errorHint}</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
{devMode && (
|
{devMode && (
|
||||||
<div style={{ textAlign: "left", overflowX: "auto" }}>
|
<div style={{ textAlign: "left", overflowX: "auto" }}>
|
||||||
<pre>{JSON.stringify(error, undefined, 2)}</pre>
|
<pre>{JSON.stringify(error, undefined, 2)}</pre>
|
||||||
|
@ -123,10 +123,17 @@ const exampleData = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const transactionError = {
|
const transactionError = {
|
||||||
code: 2000,
|
code: 7005,
|
||||||
details: "details",
|
details: {
|
||||||
hint: "this is a hint for the error",
|
requestUrl: "http://merchant-backend.taler:9966/orders/2021.340-02AD5XCC97MQM/pay",
|
||||||
message: "this is the error message with get from the app",
|
httpStatusCode: 410,
|
||||||
|
errorResponse: {
|
||||||
|
code: 2161,
|
||||||
|
hint: "The payment is too late, the offer has expired."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hint: "Error: WALLET_UNEXPECTED_REQUEST_ERROR",
|
||||||
|
message: "Unexpected error code in response",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Withdraw = createExample(TestedComponent, {
|
export const Withdraw = createExample(TestedComponent, {
|
||||||
|
Loading…
Reference in New Issue
Block a user