• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

se-edu / addressbook-level4 / 4642
94%

Build:
DEFAULT BRANCH: master
Ran 09 Aug 2018 10:03AM UTC
Jobs 1
Files 90
Run time 6s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
4642

push

travis-ci

web-flow
model: convert checked exceptions to runtime exceptions (#896)

DuplicatePersonException and PersonNotFoundException are checked
exceptions. They are thrown by methods to signify that their relevant
preconditions were violated.

Using checked exceptions for such a purpose is slightly useful in that
it will force callers to handle the case where the above preconditions
are not met, such as when the methods are called with invalid user
input.

However, it imposes a HUGE cost on callers where the preconditions are
already known to be met (e.g. in test code, or when the user input has
already been validated before hand). In such a case, callers are forced
to add try-catch blocks around the method call even if they know that
the exception will never be thrown, bloating up the code. It is also
impossible to test the catch blocks as well since correct code will
ensure that the precondition holds and thus the exception will never be
thrown, leading to reduced code coverage.

Checked exceptions also don't work very well with the Java Streams API,
since the API doesn't accept lambdas which could throw checked
exceptions.

In AB-4, the amount of code which benefits from DuplicatePersonException
and PersonNotFoundException being checked exceptions is much smaller
than the amount of code which is negatively impacted.

As such, let's make the tradeoff in the other direction, by making
DuplicatePersonException and PersonNotFoundException runtime exceptions.
New callers _could_ forget to check that the preconditions hold before
calling the methods in question (although test cases should catch that),
but this is balanced out by the huge benefit of having more concise and
testable code.

  [1/11] Remove redundant throws clauses
  [2/11] model: expose hasPerson(Person) functionality
  [3/11] AddCommand: explicitly perform duplicate person check
  [4/11] EditCommand: explicitly perform duplicate person check
  [5/11] model: make Dupli... (continued)

1425 of 1537 relevant lines covered (92.71%)

0.93 hits per line

Jobs
ID Job ID Ran Files Coverage
1 4642.1 09 Aug 2018 10:03AM UTC 0
92.71
Travis Job 4642.1
Source Files on build 4642
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #4642
  • db126b99 on github
  • Prev Build on master (#4616)
  • Next Build on master (#4643)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc