Skip to content

Handle DTO's undefined and client-side exception #3

@bibishan-pandey

Description

@bibishan-pandey

This issue is not always reproducible, but the data coming in from the API or the real-time data from the WebSocket is sometimes undefined inside the object itself, which needs to be correctly handled in the interface for the DTOs in the TypeScript.

What I mean by that is we have some DTOs that look like this:

export interface FollowupBodyType {
    auxiliary_data_hash: string;
    certs: string | undefined;
    collateral: Array<any>;
    collateral_return: Object;
    fee: string;
    inputs: Array<InputTypes>;
    mint: Array<any>;
    network_id: string | undefined;
    outputs: Array<OutputTypes>;
    reference_inputs: Array<any> | undefined;
    required_signers: Array<any> | undefined;
    script_data_hash: string;
    total_collateral: string;
    ttl: string;
    update: undefined | boolean;
    validity_start_interval: undefined | string;
    withdrawals: any;
    is_valid: boolean;
    witness_set: any;
}

If we look closely, collateral_return: Object; this property expects the Object as its data type, and we can have anything inside this. So, these interface and property data types might likely be the root cause for these exceptions.

Solution

  • Properly define the DTOs and their properties and handle them gracefully.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions