Skip to content

Commit d247e51

Browse files
Merge pull request #1725 from appwrite/fix-500s
Fix misleading 500 internal server errors
2 parents 4ba3363 + 049045d commit d247e51

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/lib/utils/specs.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { OpenAPIV3 } from 'openapi-types';
22
import { Platform, type Service } from './references';
3+
import { error } from '@sveltejs/kit';
34

45
export type SDKMethod = {
56
'rate-limit': number;
@@ -195,7 +196,14 @@ export function getSchema(id: string, api: OpenAPIV3.Document): OpenAPIV3.Schema
195196
if (schema) {
196197
return schema;
197198
}
198-
throw new Error(`Schema doesn't exist for id: ${id}`);
199+
200+
/**
201+
* It is better to show a `404` if no schema exists for a given `id`,
202+
* rather than a 500 internal server error which is, misleading in cases like this.
203+
*
204+
* It is quite possible that the user just wandered around here with a wrong docs link!
205+
*/
206+
error(404, { message: `Not found` });
199207
}
200208

201209
const specs = import.meta.glob(

src/routes/docs/references/[version]/models/[model]/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<Td>
4444
{property.description}
4545
{#if property.relatedModels}
46+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
4647
Can be one of: {@html parse(property.relatedModels)}
4748
{/if}
4849
</Td>

0 commit comments

Comments
 (0)