Skip to content

Commit

Permalink
Added error pages
Browse files Browse the repository at this point in the history
  • Loading branch information
h00s committed May 16, 2024
1 parent 12b0631 commit dcbc684
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/app/controllers/links_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ func (lc *LinksController) Get(c *raptor.Context) error {
func (lc *LinksController) Redirect(c *raptor.Context) error {
link, err := lc.Links.GetByShortID(c.Params("shortID"))
if err != nil {
return c.JSONError(err)
if raptorErr, ok := err.(*raptor.Error); ok {
if raptorErr.Code == http.StatusNotFound {
return c.Redirect("/errors/404")
}
}
return c.Redirect("/errors/500")
}
if link.Password != "" {
return c.Redirect(fmt.Sprintf("/links/%s/authorize", c.Params("shortID")))
Expand Down
Empty file.
15 changes: 15 additions & 0 deletions frontend/src/routes/errors/404/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script>
import HeaderContainer from '$lib/components/HeaderContainer.svelte'
import Privacy from '$lib/components/Privacy.svelte'
import Footer from '$lib/components/Footer.svelte'
</script>

<HeaderContainer>
<h2 class="pt-4 pb-4 text-4xl font-extrabold text-center">
404
</h2>
<p class="text-center pb-8 text-light-green">Skraćeni link ne postoji, istekao je ili je obrisan.</p>
</HeaderContainer>

<Privacy />
<Footer />
Empty file.
15 changes: 15 additions & 0 deletions frontend/src/routes/errors/500/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script>
import HeaderContainer from '$lib/components/HeaderContainer.svelte'
import Privacy from '$lib/components/Privacy.svelte'
import Footer from '$lib/components/Footer.svelte'
</script>

<HeaderContainer>
<h2 class="pt-4 pb-4 text-4xl font-extrabold text-center">
500
</h2>
<p class="text-center pb-8 text-light-green">Ups, nešto je pošlo po krivu. Pokušajte ponovo kasnije...</p>
</HeaderContainer>

<Privacy />
<Footer />
3 changes: 3 additions & 0 deletions frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ export default {
content: ['./src/**/*.{html,js,svelte,ts}'],
theme: {
extend: {
fontSize: {
'4xl': '5rem',
},
colors: {
'background-dark': '#011627',
'background-light': '#fff',
Expand Down

0 comments on commit dcbc684

Please sign in to comment.