Quantcast

Suggestion for automatic wrapping of checked exceptions inside RuntimeExceptions inside closures

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Suggestion for automatic wrapping of checked exceptions inside RuntimeExceptions inside closures

Behrang Saeedzadeh
Hi,

This has most likely been discussed before. In this yet another proposal, I
suggest adding syntax sugar to make this automated. For example, by using a
new arrow type (e.g. =>, #->, or maybe a new operator altogether: (╯°□°)╯︵
┻━┻).

So we can turn:

public class Main {
    public static void main(String[] args) throws IOException {
        final Path aDir = Paths.get(args[0]);
        Files.list(aDir).forEach(f -> {
            try {
                throw new IOException();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });
    }
}


into:

public class Main {
    public static void main(String[] args) throws IOException {
        final Path aDir = Paths.get(args[0]);
        Files.list(aDir).forEach(f (╯°□°)╯︵ ┻━┻ {
            throw new IOException();
        });
    }
}

What do you think?


Best regards,
Behrang Saeedzadeh
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Suggestion for automatic wrapping of checked exceptions inside RuntimeExceptions inside closures

Martijn Verburg
Hi Behrang,

This is the wrong list to bring up proposals like this - a good place to
start is the adoption-discuss mailing list.

Cheers,
Martijn

On 27 April 2017 at 14:10, Behrang Saeedzadeh <[hidden email]> wrote:

> Hi,
>
> This has most likely been discussed before. In this yet another proposal, I
> suggest adding syntax sugar to make this automated. For example, by using a
> new arrow type (e.g. =>, #->, or maybe a new operator altogether: (╯°□°)╯︵
> ┻━┻).
>
> So we can turn:
>
> public class Main {
>     public static void main(String[] args) throws IOException {
>         final Path aDir = Paths.get(args[0]);
>         Files.list(aDir).forEach(f -> {
>             try {
>                 throw new IOException();
>             } catch (IOException e) {
>                 throw new RuntimeException(e);
>             }
>         });
>     }
> }
>
>
> into:
>
> public class Main {
>     public static void main(String[] args) throws IOException {
>         final Path aDir = Paths.get(args[0]);
>         Files.list(aDir).forEach(f (╯°□°)╯︵ ┻━┻ {
>             throw new IOException();
>         });
>     }
> }
>
> What do you think?
>
>
> Best regards,
> Behrang Saeedzadeh
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Suggestion for automatic wrapping of checked exceptions inside RuntimeExceptions inside closures

Behrang Saeedzadeh
No worries. Will post it there.

Thanks.
On Thu, 27 Apr 2017 at 11:18 pm, Martijn Verburg <[hidden email]>
wrote:

> Hi Behrang,
>
> This is the wrong list to bring up proposals like this - a good place to
> start is the adoption-discuss mailing list.
>
> Cheers,
> Martijn
>
> On 27 April 2017 at 14:10, Behrang Saeedzadeh <[hidden email]> wrote:
>
>> Hi,
>>
>> This has most likely been discussed before. In this yet another proposal,
>> I
>> suggest adding syntax sugar to make this automated. For example, by using
>> a
>> new arrow type (e.g. =>, #->, or maybe a new operator altogether: (╯°□°)╯︵
>> ┻━┻).
>>
>> So we can turn:
>>
>> public class Main {
>>     public static void main(String[] args) throws IOException {
>>         final Path aDir = Paths.get(args[0]);
>>         Files.list(aDir).forEach(f -> {
>>             try {
>>                 throw new IOException();
>>             } catch (IOException e) {
>>                 throw new RuntimeException(e);
>>             }
>>         });
>>     }
>> }
>>
>>
>> into:
>>
>> public class Main {
>>     public static void main(String[] args) throws IOException {
>>         final Path aDir = Paths.get(args[0]);
>>         Files.list(aDir).forEach(f (╯°□°)╯︵ ┻━┻ {
>>             throw new IOException();
>>         });
>>     }
>> }
>>
>> What do you think?
>>
>>
>> Best regards,
>> Behrang Saeedzadeh
>>
>
> --
Best regards,
Behrang Saeedzadeh
Loading...