question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Catching lambda doesn't output the excpetion's message

See original GitHub issue

If I assert expectThat(catching { ... }).isNull(), and it throws, it doesn’t print the exception’s message…

In my case:

▼ Expect that com.squareup.moshi.JsonDataException:
  ✗ is null

which doesn’t help too much to identify the source of the problem.

As a plus, it would be nice to have expectDoesNotThrow { }, that would allow to add more checks on a valid result.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
robfletchercommented, Jun 23, 2019

Fixed with new expectCatchingfailed construct (or existing expectThrows).

0reactions
robfletchercommented, Jun 16, 2019

I’m working on something at the moment that does away with catching altogether. Kotlin already has the runCatching method. Instead of dealing with an exception or null we can use runCatching to produce a Result<T> that is either the value (as returned by the lambda) or the exception it threw. I think this makes much more sense for asserting against.

e.g.

expectCatching { ... }
  .failed()
  .isA<IllegalStateException>()

or

expectCatching { ... }
  .succeeded()
  .isEqualTo(...)

The existing expectThrows becomes a shorthand for the first form.

See #169

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Lambda function errors in Python
If Lambda encounters an error, it returns an exception type, message, and HTTP status code that indicates the cause of the error. The...
Read more >
AWS Step Functions: On Lambda exception, get original input?
1 Answer 1 ... You can do this using ResultPath in Catch clause which will put the exception output into a specific path...
Read more >
Avoid print exception to CloudWatch when lambda failed #578
Hi, when I throw an exception from my C# handler in AWS Lambda it is printing the exception to CloudWatch. I there any...
Read more >
Net Core Lambda - log caught exceptions - Agents
Currently we are just outputting caught exceptions into the log, but we still want to log them into the errors for analysis.
Read more >
Learning Lambda — Part 7 | The Symphonium - Symphonia
In certain situations you really will want to block further event processing until the problem causing the error is resolved, in which case...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found