php: Move server code into new phpx package
This commit is contained in:
parent
4df5f6387c
commit
2e47626900
13 changed files with 134 additions and 86 deletions
35
internal/phpx/errors.go
Normal file
35
internal/phpx/errors.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue