Improved type system
This commit is contained in:
19
src/errors/ParameterCountMismatch.go
Normal file
19
src/errors/ParameterCountMismatch.go
Normal file
@ -0,0 +1,19 @@
|
||||
package errors
|
||||
|
||||
import "fmt"
|
||||
|
||||
// ParameterCountMismatch error is created when the number of parameters doesn't match the function prototype.
|
||||
type ParameterCountMismatch struct {
|
||||
Function string
|
||||
Count int
|
||||
ExpectedCount int
|
||||
}
|
||||
|
||||
// Error generates the string representation.
|
||||
func (err *ParameterCountMismatch) Error() string {
|
||||
if err.Count > err.ExpectedCount {
|
||||
return fmt.Sprintf("Too many parameters in '%s' function call", err.Function)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("Not enough parameters in '%s' function call", err.Function)
|
||||
}
|
Reference in New Issue
Block a user