2017-10-20 15:08:25 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import "errors"
|
|
|
|
|
2017-10-28 16:02:26 +00:00
|
|
|
// InputError will be raised when the input given to the parser by the client is not right.
|
2017-10-20 15:08:25 +00:00
|
|
|
type InputError struct {
|
|
|
|
// The operation that caused the error.
|
2017-10-28 16:02:26 +00:00
|
|
|
Op string
|
2017-10-20 15:08:25 +00:00
|
|
|
// The error that occurred during the operation.
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
2017-10-28 16:02:26 +00:00
|
|
|
func (e InputError) Error() string { return "Error: " + e.Op + ": " + e.Err.Error() }
|
2017-10-20 15:08:25 +00:00
|
|
|
|
2017-10-20 15:25:47 +00:00
|
|
|
// Input Errors
|
2017-10-20 15:08:25 +00:00
|
|
|
var (
|
2017-10-28 16:02:26 +00:00
|
|
|
InputUnknownError = errors.New("Unknown Error.")
|
|
|
|
InputInvalidCommand = errors.New("Invalid command.")
|
|
|
|
InputTooManyArguments = errors.New("Too many arguments.")
|
|
|
|
InputTooFewArguments = errors.New("Too few arguments.")
|
2017-10-20 15:08:25 +00:00
|
|
|
)
|
2017-10-20 15:32:06 +00:00
|
|
|
|
2017-10-28 16:02:26 +00:00
|
|
|
// Command Errors represent errors that occur when the server is executing commands
|
2017-10-20 15:32:06 +00:00
|
|
|
var (
|
|
|
|
GetNoBitsError = errors.New("The file/directory contains zero bits!")
|
2017-10-28 16:02:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type StackError struct {
|
|
|
|
ErrorName string
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e StackError) Error() string { return e.ErrorName + ": " + e.Err.Error() }
|
|
|
|
|
|
|
|
// Stack Errors
|
|
|
|
var (
|
|
|
|
StackInvalidTypeError = StackError{"InvalidTypeError", errors.New("Invalid item type for the Stack")}
|
|
|
|
StackOverflowError = StackError{"StackOverflowError", errors.New("Stack capacity exceeded!")}
|
2017-10-28 20:40:24 +00:00
|
|
|
StackUnderflowError = StackError{"StackUnderflowError", errors.New("Stack is empty!")}
|
2017-10-28 16:02:26 +00:00
|
|
|
)
|