forked from Mirrors/elk
use sendError for other 4xx errors
This commit is contained in:
parent
27c0c4d6f2
commit
200bc3d3f1
1 changed files with 12 additions and 4 deletions
|
@ -42,17 +42,25 @@ export default defineEventHandler(async (event) => {
|
||||||
const cardUrl = decodeURIComponent(url)
|
const cardUrl = decodeURIComponent(url)
|
||||||
|
|
||||||
if (!cardUrl) {
|
if (!cardUrl) {
|
||||||
throw createError({
|
sendError(event, {
|
||||||
statusCode: 422,
|
statusCode: 422,
|
||||||
statusMessage: 'Missing cardUrl.',
|
fatal: false,
|
||||||
|
message: 'Missing cardUrl.',
|
||||||
|
name: 'OgImageError',
|
||||||
|
unhandled: false,
|
||||||
})
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof cardUrl !== 'string') {
|
if (typeof cardUrl !== 'string') {
|
||||||
throw createError({
|
sendError(event, {
|
||||||
statusCode: 422,
|
statusCode: 422,
|
||||||
statusMessage: 'cardUrl must be string.',
|
fatal: false,
|
||||||
|
message: 'cardUrl must be string.',
|
||||||
|
name: 'OgImageError',
|
||||||
|
unhandled: false,
|
||||||
})
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// If anything goes wrong, fail gracefully
|
// If anything goes wrong, fail gracefully
|
||||||
|
|
Loading…
Reference in a new issue