Skip to content

std.csv inconsistently overrides Exception.toString #10806

Open
@VPanteleev-S7

Description

@VPanteleev-S7

If you catch a CSVException and need a string representation, then depending on which Throwable.toString overload you call, you'll get a different string, missing different information.

The toString() one will return an additional row/column index, but no stack trace.

The one accepting a sink will return the stack trace as usual, but no row/column information.

import std.csv;
import std.stdio;

void main()
{
    try
        "a,b\n1,2,3\n".csvReader!(string[string])(null);
    catch (Exception e)
    {
        // Prints stack trace
        stderr.writeln(e);
        // Prints "(Row: 1, Col: 3)" but no stack trace
        stderr.writeln(e.toString());
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions