-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
onError nomally i can return custom response but now return value dosent work #747
Comments
Hi, I'm unable to reproduce the following code on Elysia 1.1.3 (latest) new Elysia()
.onError(({ code, error }) => {
if(code === "VALIDATION")
return code
})
.get('/query', () => {
return 'a'
}, {
query: t.Object({
a: t.String()
})
})
.listen(3000) Can you help provide an example code that may cause this problem? |
it happening when add @elysiajs/html |
import { Elysia, t } from "elysia";
import { html } from "@elysiajs/html";
const app = new Elysia().use(html()).onError(({ code, error }) => {
if (code === "VALIDATION") {
return code;
}
});
app.get("/", ({ query }) => "hello", { query: t.Object({ a: t.String() }) });
app.listen(3000); |
i have same issue with elysia-msgpack plugin, dunno related to plugin or elysia |
Same here. If I access an endpoint that does not have the Versions:
To reproduce: const app = new Elysia()
.onError(() => "hi, mark!")
.get("/response", () => {
throw new Error();
})
.use(html())
.get("/no-response", () => {
throw new Error();
});
app.listen({}); LE: If I |
What version of Elysia.JS is running?
elysia@1.1.3
What platform is your computer?
window x64
What steps can reproduce the bug?
it should response back "VALIDATION" right ? but
response back
{
"type": "validation",
"on": "body",
"summary": "Expected string length greater or equal to 7",
"property": "/username",
"message": "Expected string length greater or equal to 7",
"expected": {
"username": " ",
"password": " "
},
"found": {
"username": "aa",
"password": "12345678"
},
"errors": [
{
"summary": "Expected string length greater or equal to 7",
"type": 52,
"schema": {
"maxLength": 12,
"minLength": 7,
"type": "string"
},
"path": "/username",
"value": "aa",
"message": "Expected string length greater or equal to 7"
}
]
}
What is the expected behavior?
"VALIDATION"
What do you see instead?
{
"type": "validation",
"on": "body",
"summary": "Expected string length greater or equal to 7",
"property": "/username",
"message": "Expected string length greater or equal to 7",
"expected": {
"username": " ",
"password": " "
},
"found": {
"username": "aa",
"password": "12345678"
},
"errors": [
{
"summary": "Expected string length greater or equal to 7",
"type": 52,
"schema": {
"maxLength": 12,
"minLength": 7,
"type": "string"
},
"path": "/username",
"value": "aa",
"message": "Expected string length greater or equal to 7"
}
]
}
Additional information
i forks from my base-elysia git it work namorlly before update elysiajs because in package.json dependencies.elysia is latest
The text was updated successfully, but these errors were encountered: