You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by sebb <se...@gmail.com> on 2015/06/29 16:21:02 UTC
Java 7 multiple Exception catching - layout convention
Java 7 allows multiple Exceptions to be listed in a single catch
clause, which can simplify code considerably.
However, I find it a bit awkward to read the clause when no spaces are used.
Compare
} catch (NumberFormatException|IOException|ScriptException e) { // nospaces
with
} catch (NumberFormatException | IOException | ScriptException e) { //
spaced out
I find the second version with spaces both sides of the "|" character
much easier to read.
This is particularly true where the exception name starts with the
letters "Ill" as in
} catch (NumberFormatException|IllegalArgumentException|ScriptException
e) { // nospaces
Agreed?
Re: Java 7 multiple Exception catching - layout convention
Posted by Vladimir Sitnikov <si...@gmail.com>.
+1
Vladimir
Re: Java 7 multiple Exception catching - layout convention
Posted by Nachiket Kate <na...@gmail.com>.
+1
On Tue, Jun 30, 2015 at 3:33 AM, Milamber <mi...@apache.org> wrote:
>
>
> On 29/06/2015 16:21, sebb wrote:
>
>> Java 7 allows multiple Exceptions to be listed in a single catch
>> clause, which can simplify code considerably.
>>
>> However, I find it a bit awkward to read the clause when no spaces are
>> used.
>>
>> Compare
>>
>> } catch (NumberFormatException|IOException|ScriptException e) { //
>> nospaces
>>
>> with
>>
>> } catch (NumberFormatException | IOException | ScriptException e) { //
>> spaced out
>>
>>
>>
>> I find the second version with spaces both sides of the "|" character
>> much easier to read.
>>
>> This is particularly true where the exception name starts with the
>> letters "Ill" as in
>>
>> } catch (NumberFormatException|IllegalArgumentException|ScriptException
>> e) { // nospaces
>>
>> Agreed?
>>
>
> Yes, the spaces version seems better for have a better readable.
> Milamber
>
>
>
>>
>
--
<---- Nachiket Kate ---->
Re: Java 7 multiple Exception catching - layout convention
Posted by Milamber <mi...@apache.org>.
On 29/06/2015 16:21, sebb wrote:
> Java 7 allows multiple Exceptions to be listed in a single catch
> clause, which can simplify code considerably.
>
> However, I find it a bit awkward to read the clause when no spaces are used.
>
> Compare
>
> } catch (NumberFormatException|IOException|ScriptException e) { // nospaces
>
> with
>
> } catch (NumberFormatException | IOException | ScriptException e) { //
> spaced out
>
>
>
> I find the second version with spaces both sides of the "|" character
> much easier to read.
>
> This is particularly true where the exception name starts with the
> letters "Ill" as in
>
> } catch (NumberFormatException|IllegalArgumentException|ScriptException
> e) { // nospaces
>
> Agreed?
Yes, the spaces version seems better for have a better readable.
Milamber
>
Re: Java 7 multiple Exception catching - layout convention
Posted by Philippe Mouawad <ph...@gmail.com>.
I can only approve
On Tue, Jun 30, 2015 at 7:35 AM, Felix Schumacher <
felix.schumacher@internetallee.de> wrote:
>
>
> Am 29. Juni 2015 16:21:02 MESZ, schrieb sebb <se...@gmail.com>:
> >Java 7 allows multiple Exceptions to be listed in a single catch
> >clause, which can simplify code considerably.
> >
> >However, I find it a bit awkward to read the clause when no spaces are
> >used.
> >
> >Compare
> >
> >} catch (NumberFormatException|IOException|ScriptException e) { //
> >nospaces
> >
> >with
> >
> >} catch (NumberFormatException | IOException | ScriptException e) { //
> >spaced out
> >
>
> +1
>
> Felix
>
> >
> >
> >I find the second version with spaces both sides of the "|" character
> >much easier to read.
> >
> >This is particularly true where the exception name starts with the
> >letters "Ill" as in
> >
> >} catch (NumberFormatException|IllegalArgumentException|ScriptException
> >e) { // nospaces
> >
> >Agreed?
>
>
--
Cordialement.
Philippe Mouawad.
Re: Java 7 multiple Exception catching - layout convention
Posted by Felix Schumacher <fe...@internetallee.de>.
Am 29. Juni 2015 16:21:02 MESZ, schrieb sebb <se...@gmail.com>:
>Java 7 allows multiple Exceptions to be listed in a single catch
>clause, which can simplify code considerably.
>
>However, I find it a bit awkward to read the clause when no spaces are
>used.
>
>Compare
>
>} catch (NumberFormatException|IOException|ScriptException e) { //
>nospaces
>
>with
>
>} catch (NumberFormatException | IOException | ScriptException e) { //
>spaced out
>
+1
Felix
>
>
>I find the second version with spaces both sides of the "|" character
>much easier to read.
>
>This is particularly true where the exception name starts with the
>letters "Ill" as in
>
>} catch (NumberFormatException|IllegalArgumentException|ScriptException
>e) { // nospaces
>
>Agreed?