@@ -55,13 +55,13 @@ type contextKeyStruct struct{}
5555var contextKey = contextKeyStruct {}
5656
5757var (
58- InvalidRequestError = errors .New ("not a FrankenPHP request" )
59- AlreadyStartedError = errors .New ("FrankenPHP is already started" )
60- InvalidPHPVersionError = errors .New ("FrankenPHP is only compatible with PHP 8.2+" )
61- MainThreadCreationError = errors .New ("error creating the main thread" )
62- RequestContextCreationError = errors .New ("error during request context creation" )
63- ScriptExecutionError = errors .New ("error during PHP script execution" )
64- NotRunningError = errors .New ("FrankenPHP is not running. For proper configuration visit: https://frankenphp.dev/docs/config/#caddyfile-config" )
58+ ErrInvalidRequest = errors .New ("not a FrankenPHP request" )
59+ ErrAlreadyStarted = errors .New ("FrankenPHP is already started" )
60+ ErrInvalidPHPVersion = errors .New ("FrankenPHP is only compatible with PHP 8.2+" )
61+ ErrMainThreadCreation = errors .New ("error creating the main thread" )
62+ ErrRequestContextCreation = errors .New ("error during request context creation" )
63+ ErrScriptExecution = errors .New ("error during PHP script execution" )
64+ ErrNotRunning = errors .New ("FrankenPHP is not running. For proper configuration visit: https://frankenphp.dev/docs/config/#caddyfile-config" )
6565
6666 isRunning bool
6767
@@ -189,7 +189,7 @@ func calculateMaxThreads(opt *opt) (int, int, int, error) {
189189 return opt .numThreads , numWorkers , opt .maxThreads , nil
190190 }
191191
192- if ! numThreadsIsSet && ! maxThreadsIsSet {
192+ if ! numThreadsIsSet {
193193 if numWorkers >= maxProcs {
194194 // Start at least as many threads as workers, and keep a free thread to handle requests in non-worker mode
195195 opt .numThreads = numWorkers + 1
@@ -218,7 +218,7 @@ func calculateMaxThreads(opt *opt) (int, int, int, error) {
218218// Init starts the PHP runtime and the configured workers.
219219func Init (options ... Option ) error {
220220 if isRunning {
221- return AlreadyStartedError
221+ return ErrAlreadyStarted
222222 }
223223 isRunning = true
224224
@@ -265,7 +265,7 @@ func Init(options ...Option) error {
265265 config := Config ()
266266
267267 if config .Version .MajorVersion < 8 || (config .Version .MajorVersion == 8 && config .Version .MinorVersion < 2 ) {
268- return InvalidPHPVersionError
268+ return ErrInvalidPHPVersion
269269 }
270270
271271 if config .ZTS {
@@ -381,7 +381,7 @@ func updateServerContext(thread *phpThread, fc *frankenPHPContext, isWorkerReque
381381 )
382382
383383 if ret > 0 {
384- return RequestContextCreationError
384+ return ErrRequestContextCreation
385385 }
386386
387387 return nil
@@ -390,12 +390,12 @@ func updateServerContext(thread *phpThread, fc *frankenPHPContext, isWorkerReque
390390// ServeHTTP executes a PHP script according to the given context.
391391func ServeHTTP (responseWriter http.ResponseWriter , request * http.Request ) error {
392392 if ! isRunning {
393- return NotRunningError
393+ return ErrNotRunning
394394 }
395395
396396 fc , ok := fromContext (request .Context ())
397397 if ! ok {
398- return InvalidRequestError
398+ return ErrInvalidRequest
399399 }
400400
401401 fc .responseWriter = responseWriter
0 commit comments