wisski-cloud-distillery/internal/phpx/errors.go
2022-11-16 13:07:15 +01:00

35 lines
715 B
Go

package phpx
import "fmt"
// Common PHP Errors
const (
errInit = "Server initialization failed"
errClosed = "Server closed"
errReceive = "Failed to decode response"
)
// PHPError represents an error during PHPServer logic
type ServerError struct {
Message string
Err error
}
// Unwrap returns the underlying error
func (err ServerError) Unwrap() error {
return err.Err
}
func (err ServerError) Error() string {
if err.Err == nil {
return fmt.Sprintf("PHPServer: %s", err.Message)
}
return fmt.Sprintf("PHPServer: %s: %s", err.Message, err.Err)
}
// Throwable represents an error during php code
type Throwable string
func (throwable Throwable) Error() string {
return string(throwable)
}