MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / makeError

Method makeError

packages/server/src/api/rest/index.ts:2645–2670  ·  view source on GitHub ↗
(
        code: keyof typeof this.errors,
        detail?: string,
        status?: number,
        otherFields: Record<string, any> = {},
    )

Source from the content-addressed store, hash-verified

2643 }
2644
2645 private makeError(
2646 code: keyof typeof this.errors,
2647 detail?: string,
2648 status?: number,
2649 otherFields: Record<string, any> = {},
2650 ) {
2651 status = status ?? this.errors[code]?.status ?? 500;
2652 const error: any = {
2653 status,
2654 code: paramCase(code),
2655 title: this.errors[code]?.title,
2656 };
2657
2658 if (detail) {
2659 error.detail = detail;
2660 }
2661
2662 Object.assign(error, otherFields);
2663
2664 return {
2665 status,
2666 body: {
2667 errors: [error],
2668 },
2669 };
2670 }
2671
2672 private makeUnsupportedModelError(model: string) {
2673 return this.makeError('unsupportedModel', `Model ${model} doesn't exist`);

Callers 15

handleRequestMethod · 0.95
handleGenericErrorMethod · 0.95
processSingleReadMethod · 0.95
processFetchRelatedMethod · 0.95
processNestedCreateMethod · 0.95
processNestedUpdateMethod · 0.95

Calls 1

paramCaseFunction · 0.90

Tested by

no test coverage detected