This commit updates the wire format of the phpx server. Instead of being string-based, messages sent back and forth between go and php are now base64-encoded DEFLATEd strings. This makes them a lot smaller and faster to send.
36 lines
756 B
Go
36 lines
756 B
Go
package phpx
|
|
|
|
import "fmt"
|
|
|
|
// Common PHP Errors
|
|
const (
|
|
errInit = "Server initialization failed"
|
|
errClosed = "Server closed"
|
|
errSend = "Failed to encode request"
|
|
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)
|
|
}
|