From 6e037c025a3c8d18e9ff771e22cdb4c0ba6e8b5e Mon Sep 17 00:00:00 2001 From: raonismaneoto Date: Wed, 3 Jun 2020 18:12:58 -0300 Subject: [PATCH] creating error module --- errors/errors.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 errors/errors.go diff --git a/errors/errors.go b/errors/errors.go new file mode 100644 index 0000000..2bcb8d6 --- /dev/null +++ b/errors/errors.go @@ -0,0 +1,20 @@ +package errors + +import ( + "log" + "os" +) + +type CustomError struct { + Code int + Message string +} + +func (e *CustomError) String() string{ + return e.Message + "\n Code: " + string(e.Code) +} + +func (e *CustomError) panic() { + log.Println(e.Message) + os.Exit(e.Code) +}