Skip to content

Improve error message #121

@martinmeow

Description

@martinmeow

When validationMetadatasToSchemas fails to generate the spec the thrown error has very little information.

The class causing the error looks like this:

export class AssessmentItemDto {
  @IsString()
  @MaxLength(100)
  key: string;

  @IsString()
  @MaxLength(50)
  label: string;

  @IsOptional()
  @IsIn([true, false, null])
  value: boolean | null;

  @IsString()
  @MaxLength(100)
  remark: string;
}

The error is caused by @IsIn([true, false, null]). The error message is TypeError: undefined is not an object (evaluating 'item.type'). It would be nice if is said something like this:

Failed to generate spec while evaluating:
  class: `AssessmentItemDto`,
  property: `value`,
  decorator:`@IsIn`,
  message: `TypeError: undefined is not an object (evaluating 'item.type')`
  at: (file name and line number)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions