Skip to content

Commit

Permalink
fix: update error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Dakskihedron authored and karlvr committed Jul 2, 2024
1 parent 9019caf commit 128cc20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion templates/validationGeneric.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function model{{className nativeType.parentType}}FromRequestContent(name: string

function model{{className nativeType.parentType}}ToResponseContent(name: string, value: {{nativeType}}, knownKeys: Record<string, boolean> = {}): ToResponse<{{#if discriminator}}Omit<{{nativeType.parentType}}, {{{stringLiteral discriminator.serializedName}}}>{{else}}{{nativeType}}{{/if}}> {
{{#ifeq purpose 'METADATA'}}
throw 'toJson not supported for metadata schemas'
throw 'toResponse not supported for metadata schemas'
{{else}}
if (typeof value !== 'object' || value === undefined || value === null) {
throw `Invalid type for ${name}: expected object got ${typeof value}`
Expand Down
4 changes: 2 additions & 2 deletions templates/validationOneOf.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function oneOf{{className nativeType.parentType}}FromRequest(name: string
}
{{/each}}

throw `Failed to parse JSON for any member of ${name}: ${errors.join('\n')}`
throw `Failed to parse request for any member of ${name}: ${errors.join('\n')}`
{{/if}}
}

Expand All @@ -44,7 +44,7 @@ export function oneOf{{className nativeType.parentType}}ToResponse(name: string,
}
{{/each}}

throw `Failed to create JSON for any member of ${name}: ${errors.join('\n')}`
throw `Failed to create response for any member of ${name}: ${errors.join('\n')}`
{{/if}}
}
{{>nestedValidation}}

0 comments on commit 128cc20

Please sign in to comment.