Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP: Handle request errors in PHPRequestHandler, return response code 500 #1249

Merged
merged 10 commits into from
Apr 17, 2024
32 changes: 21 additions & 11 deletions packages/php-wasm/universal/src/lib/php-request-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,27 @@ export class PHPRequestHandler implements RequestHandler {
);
}

return await this.php.run({
relativeUri: ensurePathPrefix(
toRelativeUrl(requestedUrl),
this.#PATHNAME
),
protocol: this.#PROTOCOL,
method: request.method || preferredMethod,
body,
scriptPath,
headers,
});
try {
return await this.php.run({
relativeUri: ensurePathPrefix(
toRelativeUrl(requestedUrl),
this.#PATHNAME
),
protocol: this.#PROTOCOL,
method: request.method || preferredMethod,
body,
scriptPath,
headers,
});
} catch (error) {
return (
error as {
message: string;
response: PHPResponse;
source: string;
}
kozer marked this conversation as resolved.
Show resolved Hide resolved
).response;
}
} finally {
release();
}
Expand Down
Loading