Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonUnsupportedObjectError.toString does not print cause #17954

Closed
kevmoo opened this issue Apr 2, 2014 · 5 comments
Closed

JsonUnsupportedObjectError.toString does not print cause #17954

kevmoo opened this issue Apr 2, 2014 · 5 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-m library-convert type-enhancement A request for a change that isn't a bug

Comments

@kevmoo
Copy link
Member

kevmoo commented Apr 2, 2014

When debugging errors, seeing the cause would be helpful

@lrhn
Copy link
Member

lrhn commented Apr 2, 2014

Added Area-Library label.

@kevmoo kevmoo added Type-Enhancement library-convert area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Apr 2, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@lrhn lrhn added the core-m label Aug 11, 2017
@dgrove
Copy link
Contributor

dgrove commented Aug 24, 2017

This bug is showing up as high priority for internal users.

@kevmoo
Copy link
Member Author

kevmoo commented Aug 24, 2017

I end up doing silly like this:

String prettyJson(obj) {
  try {
    return const JsonEncoder.withIndent(' ').convert(obj);
  } on JsonUnsupportedObjectError catch (e) {
    var error = e;

    while (error is JsonUnsupportedObjectError) {
      stderr.writeln([
        error,
        "${error.unsupportedObject} - (${error.unsupportedObject.runtimeType})",
        error.cause == null ? null : "Nested cause: ${error.cause}",
        error.stackTrace
      ].where((i) => i != null).join('\n'));

      error = error.cause;
    }
    rethrow;
  }
}

@floitschG
Copy link
Contributor

Fixed, and we even added a partialResult field that shows the string that was constructed so far.

The nested cause information and the partialResult are too big to include into the toString, though.

@kevmoo
Copy link
Member Author

kevmoo commented Aug 25, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-m library-convert type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants