|
Re: catching errors from linked processes: simplest way?: msg#00325lang.erlang.general
How about writing a small library function: assert(false, Msg) -> exit(Msg); assert(true, _) -> true. foo(A, B) -> assert(A, only_applies_under_condition_a), bar(B). /Uffe On Tue, 22 Apr 2003, Chris Pressey wrote: >However, I got to another sticking point. I have several functions that >only make sense under a certain condition, let's call it A. The >functions used to look like this: > > foo(A, B) -> > case A of > true -> > bar(B); > false -> > {error, only_applies_under_condition_a} > end. > >Now, they look like this: > > foo(A, B) -> > A = true, bar(B). > >which is *much* easier to read. :) > >However, the error message has gone from a nice, >informative one, to the generic {badmatch, true}, which is >not all that great (I'd like to be able to give the >(probably non-Erlang-literate) user a message as to exactly >why it crashed.) -- Ulf Wiger, Senior Specialist, / / / Architecture & Design of Carrier-Class Software / / / Strategic Product & System Management / / / Ericsson AB, Connectivity and Control Nodes |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: catching errors from linked processes: simplest way?: 00325, Vance Shipley |
|---|---|
| Next by Date: | Re: optimization ?: 00325, HP Wei |
| Previous by Thread: | Re: catching errors from linked processes: simplest way?i: 00325, Raimo Niskanen |
| Next by Thread: | TIPC: Carrier Grade Cluster Protocol (Slightly Off Topic): 00325, Mickael Remond |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |