feat: add some magic to errors

This commit is contained in:
Stavros 2024-08-15 14:03:18 +03:00
parent db570f6204
commit 4d962dc560
5 changed files with 50 additions and 33 deletions

View File

@ -1,33 +0,0 @@
'use client';
import { Button } from '@/components/ui/Button';
import React from 'react';
export default function TestErrorPage() {
const fetchFaultyApi = async () => {
const response = await fetch('/api/test-error');
const json = await response.json();
return json;
};
return (
<div className="card d-flex">
<Button
type="button"
onClick={() => {
throw new Error('Sentry Frontend Error');
}}
>
Throw error
</Button>
<Button
type="button"
onClick={async () => {
await fetchFaultyApi();
}}
>
Fetch faulty API
</Button>
</div>
);
}

View File

@ -0,0 +1,36 @@
"use client";
import { Button } from "@/components/ui/Button";
import React from "react";
export function TestErrorPage() {
const fetchFaultyApi = async () => {
const response = await fetch("/api/test-error");
const json = await response.json();
return json;
};
return (
<div className="card d-flex p-3">
<h2>Congratulations! You found the secret Tipi Test Page 🎉</h2>
<p className="card-subtitle">Now make it fail!</p>
<Button
className="mb-2"
type="button"
onClick={() => {
throw new Error("Sentry Frontend Error");
}}
>
Throw error
</Button>
<Button
type="button"
onClick={async () => {
await fetchFaultyApi();
}}
>
Fetch faulty API
</Button>
</div>
);
}

View File

@ -0,0 +1 @@
export { TestErrorPage } from "./TestErrorPage";

View File

@ -0,0 +1,12 @@
import type { Metadata } from "next";
import { TestErrorPage } from "./components/TestErrorPage";
export async function generateMetadata(): Promise<Metadata> {
return {
title: "Test Page - Tipi",
};
}
export default function TestPage() {
return <TestErrorPage />;
}

View File

@ -224,6 +224,7 @@
"HEADER_SOURCE_CODE": "Source code",
"HEADER_SPONSOR": "Sponsor",
"HEADER_UPDATE_AVAILABLE": "Update available",
"HEADER_TEST_PAGE": "Test Page",
"INTERNAL_SERVER_ERROR": "Internal server error",
"LINKS_ADD_SUBMIT": "Submit",
"LINKS_ADD_SUBTITLE": "Add external link to the dashboard",