diff options
| author | Bobby <[email protected]> | 2025-12-19 18:52:39 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2025-12-19 18:52:39 +0530 |
| commit | ed74f2cffa902a3e9aeb614f8dcf65f04658a597 (patch) | |
| tree | a86fe689686774b2915608a511ba57822b0b6521 /utils | |
| parent | a42fcbc8149f482d65a53ddcdc7bcfaaea359c69 (diff) | |
| download | lain-ed74f2cffa902a3e9aeb614f8dcf65f04658a597.tar.xz lain-ed74f2cffa902a3e9aeb614f8dcf65f04658a597.zip | |
error controllers, types and templates and layouts
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/shortcuts/error.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/utils/shortcuts/error.go b/utils/shortcuts/error.go new file mode 100644 index 0000000..4cb0e81 --- /dev/null +++ b/utils/shortcuts/error.go @@ -0,0 +1,25 @@ +package shortcuts + +import ( + "errors" + "lain/types" + "lain/utils/meta" + + "github.com/gofiber/fiber/v2" +) + +func BuildErrorMessage(err error, alternateString string) error { + if err != nil { + return err + } + + return errors.New(alternateString) +} + +func RenderError(error types.TemplateError) error { + meta.SetPageTitle(error.Context, error.PageTitle) + return RenderWithStatus(error.Context, "error", fiber.Map{ + "ErrorTitle": error.PageTitle, + "ErrorMessage": error.ErrorMessage.Error(), + }, error.StatusCode) +} |
