Error

error is an interface type built into Go. An error variable represents any value that can be described as a string.

The interface consists of a single function, Error(), which returns a string error message.

Go does not support the conventional try-and-catch block for error handling. Instead, when something unexpected happens, it returns an error.


// This struct implements the error interface
type ErrorCustom struct {
    msg string
🇧🇷

func (and CustomError) Error() string {
    return msg
}
                        
error.go