Added project files
This commit is contained in:
parent
84547f6dcb
commit
94a5aff260
23 changed files with 1042 additions and 1 deletions
55
core/errors.go
Normal file
55
core/errors.go
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Copyright (c) 2025, Julian Müller (ChaoticByte)
|
||||
|
||||
package core
|
||||
|
||||
import "fmt"
|
||||
|
||||
type HttpStatusCodeError struct {
|
||||
Url string
|
||||
StatusCode int
|
||||
}
|
||||
|
||||
func (err *HttpStatusCodeError) Error() string {
|
||||
var e string
|
||||
switch err.StatusCode {
|
||||
case 400:
|
||||
e = "Bad Request"
|
||||
case 401:
|
||||
e = "Unauthorized"
|
||||
case 403:
|
||||
e = "Forbidden"
|
||||
case 404:
|
||||
e = "Not Found"
|
||||
case 500, 502, 504:
|
||||
e = "Server Error"
|
||||
case 503:
|
||||
e = "Service Unavailable"
|
||||
default:
|
||||
e = "Request failed"
|
||||
}
|
||||
return fmt.Sprintf("%v - got status code %v while fetching %v", e, err.StatusCode, err.Url)
|
||||
}
|
||||
|
||||
type FileExistsError struct {
|
||||
Filename string
|
||||
}
|
||||
|
||||
func (err *FileExistsError) Error() string {
|
||||
return "File '" + err.Filename + "' already exists. See the available options on how to proceed."
|
||||
}
|
||||
|
||||
type FormatNotFoundError struct {
|
||||
FormatName string
|
||||
}
|
||||
|
||||
func (err *FormatNotFoundError) Error() string {
|
||||
return "Format " + err.FormatName + " is not available."
|
||||
}
|
||||
|
||||
type ChapterNotFoundError struct {
|
||||
ChapterNum int
|
||||
}
|
||||
|
||||
func (err *ChapterNotFoundError) Error() string {
|
||||
return fmt.Sprintf("Chapter %v not found.", err.ChapterNum)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue