Documentation
¶
Index ¶
- func Throw(exp *Exception)
- func Try(cb func()) *exceptionHandler
- type Exception
- func AssertionError(args ...interface{}) *Exception
- func ConnectionError(args ...interface{}) *Exception
- func EOFError(args ...interface{}) *Exception
- func IndexError(args ...interface{}) *Exception
- func LookupError(args ...interface{}) *Exception
- func NetworkError(args ...interface{}) *Exception
- func New(exceptionType ExceptionType, args ...interface{}) *Exception
- func PermissionError(args ...interface{}) *Exception
- func ReferenceError(args ...interface{}) *Exception
- func SyntaxError(args ...interface{}) *Exception
- func TimeoutError(args ...interface{}) *Exception
- func TypeError(args ...interface{}) *Exception
- func ValueError(args ...interface{}) *Exception
- type ExceptionType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Throw ¶
func Throw(exp *Exception)
Throw is used to throw an exception. You can use some builtin Exceptions such as LookupError, PermissionError, NetworkError etc. which are offered by this library or you can also create your custom Exception and throw. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
Types ¶
type Exception ¶
type Exception struct { Message string Type ExceptionType StackTrace string }
func AssertionError ¶
func AssertionError(args ...interface{}) *Exception
AssertionError should be used to throw an exception indicating assertion failure. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func ConnectionError ¶
func ConnectionError(args ...interface{}) *Exception
ConnectionError should be used to throw an exception indicating connection related failure. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func EOFError ¶
func EOFError(args ...interface{}) *Exception
EOFError should be used to throw an exception indicating end of file related issue. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func IndexError ¶
func IndexError(args ...interface{}) *Exception
IndexError should be used to throw an exception indicating index is out of bound failure. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func LookupError ¶
func LookupError(args ...interface{}) *Exception
LookupError should be used to throw an exception indicating the key is unavailable in a map. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func NetworkError ¶
func NetworkError(args ...interface{}) *Exception
NetworkError should be used to throw an exception indicating the network related issue. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func New ¶
func New(exceptionType ExceptionType, args ...interface{}) *Exception
New is constructor which is used to create a new Exception
func PermissionError ¶
func PermissionError(args ...interface{}) *Exception
PermissionError should be used to throw an exception indicating the permission related issue. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func ReferenceError ¶
func ReferenceError(args ...interface{}) *Exception
ReferenceError should be used to throw an exception indicating the reference related of issue. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func SyntaxError ¶
func SyntaxError(args ...interface{}) *Exception
SyntaxError should be used to throw an exception indicating the reference related of issue. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func TimeoutError ¶
func TimeoutError(args ...interface{}) *Exception
TimeoutError should be used to throw an exception indicating the Timeout related issue. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func TypeError ¶
func TypeError(args ...interface{}) *Exception
TypeError should be used to throw an exception indicating the type is not as expected. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
func ValueError ¶
func ValueError(args ...interface{}) *Exception
ValueError should be used to throw an exception indicating the value is not in correct format. It accepts error message as an optional argument. Otherwise the ExceptionType is used as default error message.
type ExceptionType ¶
type ExceptionType string
const ( UnknownErrorType ExceptionType = "UnknownError" IndexErrorType ExceptionType = "IndexError" RuntimeErrorType ExceptionType = "RuntimeError" ValueErrorType ExceptionType = "ValueError" NetworkErrorType ExceptionType = "NetworkError" SyntaxErrorType ExceptionType = "SyntaxError" PermissionErrorType ExceptionType = "PermissionError" TimeoutErrorType ExceptionType = "TimeoutError" TypeErrorType ExceptionType = "TypeError" AssertionErrorType ExceptionType = "AssertionError" ConnectionErrorType ExceptionType = "ConnectionError" ReferenceErrorType ExceptionType = "ReferenceError" EOFErrorType ExceptionType = "EOFError" LookupErrorType ExceptionType = "LookupError" )
func In ¶
func In(exceptionTypes ...ExceptionType) []ExceptionType
In accepts a variable number of ExceptionType as arguments. It creates a list ExceptionType that will be used for the mathcing of exception.