Skip to content

Commit

Permalink
Merge pull request #1725 from appwrite/fix-500s
Browse files Browse the repository at this point in the history
Fix misleading 500 internal server errors
  • Loading branch information
thejessewinton authored Jan 31, 2025
2 parents 4ba3363 + 049045d commit d247e51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/utils/specs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { OpenAPIV3 } from 'openapi-types';
import { Platform, type Service } from './references';
import { error } from '@sveltejs/kit';

export type SDKMethod = {
'rate-limit': number;
Expand Down Expand Up @@ -195,7 +196,14 @@ export function getSchema(id: string, api: OpenAPIV3.Document): OpenAPIV3.Schema
if (schema) {
return schema;
}
throw new Error(`Schema doesn't exist for id: ${id}`);

/**
* It is better to show a `404` if no schema exists for a given `id`,
* rather than a 500 internal server error which is, misleading in cases like this.
*
* It is quite possible that the user just wandered around here with a wrong docs link!
*/
error(404, { message: `Not found` });
}

const specs = import.meta.glob(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<Td>
{property.description}
{#if property.relatedModels}
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
Can be one of: {@html parse(property.relatedModels)}
{/if}
</Td>
Expand Down

0 comments on commit d247e51

Please sign in to comment.