nice pattern for running a series of error checks

M

Martin DeMello

came up with this while refactoring some code:

case
when test_1; report_error test_1
when test_2; report_error test_2
when test_3; report_error test_3
else; do_success

the nice thing is that it automatically exits the structure at the
first failing test.

martin
 
S

Sylvain Joyeux

case
when test_1; report_error test_1
when test_2; report_error test_2
when test_3; report_error test_3
else; do_success

the nice thing is that it automatically exits the structure at the
first failing test.

Well. The preferred way to report error should be raising exceptions, in
which case everything up to the nearest error handler is exited at the
first failing test...

Sylvain
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top