Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E612F200BC5 for ; Tue, 22 Nov 2016 15:49:18 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id E4A76160B0C; Tue, 22 Nov 2016 14:49:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1309A160B0A for ; Tue, 22 Nov 2016 15:49:17 +0100 (CET) Received: (qmail 67135 invoked by uid 500); 22 Nov 2016 14:49:17 -0000 Mailing-List: contact user-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@curator.apache.org Delivered-To: mailing list user@curator.apache.org Received: (qmail 67126 invoked by uid 99); 22 Nov 2016 14:49:17 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Nov 2016 14:49:17 +0000 Received: from mail-qk0-f171.google.com (mail-qk0-f171.google.com [209.85.220.171]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id E74021A002B for ; Tue, 22 Nov 2016 14:49:16 +0000 (UTC) Received: by mail-qk0-f171.google.com with SMTP id n21so27184335qka.3 for ; Tue, 22 Nov 2016 06:49:16 -0800 (PST) X-Gm-Message-State: AKaTC02DEVFNnjfRCNSqe8COnZYw3sf90LuJj81cQszDFHMXYJvmjUPDes1RVqSeBLYXnHh2NC7tPXfoKWNMPw== X-Received: by 10.55.65.75 with SMTP id o72mr20902635qka.19.1479826155835; Tue, 22 Nov 2016 06:49:15 -0800 (PST) MIME-Version: 1.0 References: <36fada3f031962c1cbcbea84ca57a20d@ant.ee> <2e027f8a0753ece9d98e4cd49fd0f56b@ant.ee> In-Reply-To: From: John Vines Date: Tue, 22 Nov 2016 14:49:05 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Why do you throw exceptions of class Exception To: user@curator.apache.org Content-Type: multipart/alternative; boundary=001a114abda45970db0541e4e04e archived-at: Tue, 22 Nov 2016 14:49:19 -0000 --001a114abda45970db0541e4e04e Content-Type: text/plain; charset=UTF-8 http://asfmail.lucidworks.io/mail_files/curator-dev/201408.mbox/%3CCAFAMeY+hPnbkKHkhgAjNh5Rv_3gTtmJSZFkecHFXUKkH=_hdLg@mail.gmail.com%3E This was the last big convo we had on this, iirc On Tue, Nov 22, 2016 at 6:39 AM Flavio Junqueira wrote: > I have actually come across the same thing and have been wondering why it > is throwing a generic exception. Even if it is executing user code, it > could still wrap it with something like CuratorException. > > If anyone here has some more insight on the reason for throwing Exception, > I'd love to hear. > > Thanks, > -Flavio > > > On 21 Nov 2016, at 13:21, Vadim wrote: > > Imesha, > > I can't comment particularly this piece of code. The initial > question was too general and I thought about QueueConsumer, for example, or > other type of listener that is implemented by customer and executes > customer code. > > It might be some type of dependency for that function that could > depend from customer code. If you want to go deeper - you can analyze > source and check if there are such. May be there is no reason for that > also. :) > > > Vadim. > > On 2016-11-21 12:32, Imesha Sudasingha wrote: > > Hello Vadim, > > I didn't get your point. What I mean is, suppose we are going to create an > ZNode. Consider the following example, > > curatorFrameworkInstance.create().forPath("/ZNode/path"); > > In the above code, we have to surround with a try/catch since it is > expected to throw an exception of type *Exception*. According to your > explanation, how can this be a code written by me? What I am doing above is > just executing the methods provided. Can you elaborate on that? > > -Imesha > > > > On 21 November 2016 at 13:45, Vadim wrote: > > Hello Imesha, > > As user of curator, I guess this is because Curator suppose to > execute external code (like yours) and it does not know what type of the > exception it will throw in advance. If you define specific exception -- > your code will be dependent on that and thus "hard dependency" arise. It > breaks DIP principle from SOLID ( > https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)) that is not > good. > > Vadim. > > > > On 2016-11-21 09:12, Imesha Sudasingha wrote: > > Hi all, > > I was curious on why most of the methods in *CuratorFramework* throw > exceptions of the type *Exception *which is the base class? In Zookeeper, > they have specific set of custom exceptions like ZooKeeperException and so > on. Do you have a specific reason for that? > > Thanks in advance! > > -Imesha > > -- > *Imesha Sudasingha* > Undergraduate of Department of Computer Science and Engineering, > University of Moratuwa. > > > > > -- > *Imesha Sudasingha* > Undergraduate of Department of Computer Science and Engineering, > University of Moratuwa. > > > --001a114abda45970db0541e4e04e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
http://asfmail.lucidworks.io/mail_files/curator-dev/20140= 8.mbox/%3CCAFAMeY+hPnbkKHkhgAjNh5Rv_3gTtmJSZFkecHFXUKkH=3D_hdLg@mail.gmail.= com%3E

This was the last big convo we had on this, i= irc

On Tue, Nov 2= 2, 2016 at 6:39 AM Flavio Junqueira <f= pj@apache.org> wrote:
I have actually come acro= ss the same thing and have been wondering why it is throwing a generic exce= ption. Even if it is executing user code, it could still wrap it with somet= hing like CuratorException.

If anyone here has some more insight on the= reason for throwing Exception, I'd love to hear.

Thanks,
-Flavio
=C2=A0
On 21 Nov 2016, at 13:21, Vadim <vadim@ant.ee= > wrote:

I= mesha,

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 I can't= comment particularly this piece of code. The initial question was too gene= ral and I thought about QueueConsumer, for example, or other type of listen= er that is implemented by customer and executes customer code.

=C2=A0=C2=A0=C2=A0=C2=A0 It might be some type of dependency= for that function that could depend from customer code. If you want to go = deeper - you can analyze source and check if there are such. May be there i= s no reason for that also. :)

=C2=A0

Vadim.

On 2016-11-21 12:32, Imesha Sudasingha wrote:

Hello Vadim,
=C2=A0
I didn't get your point. What I mean is, suppo= se we are going to create an ZNode. Consider the following example,
=C2=A0
curatorFrameworkInstance.create().forPath("/Z= Node/path");
=C2=A0
In the above code, we have to surround with a try/= catch since it is expected to throw an exception of type Exception. According to your explanation, how can this b= e a code written by me? What I am doing above is just executing the methods= provided. Can you elaborate on that?
=C2=A0
-Imesha
=C2=A0
=C2=A0

On 21 November 2016 at 13:45, Vadim <vadim@ant.ee> wrote:

Hello Imesha,

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 As user of curator, I guess this is= because Curator suppose to execute external code (like yours) and it does = not know what type of the exception it will throw in advance. If you define= specific exception -- your code will be dependent on that and thus "h= ard dependency" arise. It breaks DIP principle from SOLID (https://en.wikipedia.org/wiki/SOLID_(object-orien= ted_design)) that is not good.

Vadim.

=C2=A0
=C2=A0

On 2016-11-21 09:12, Imesha Sudasingha wrote:

Hi all,
=C2=A0
I was curious on why most of the methods in=C2=A0<= strong class=3D"gmail_msg">CuratorFramework=C2=A0throw exceptions = of the type=C2=A0Exception which is th= e base class?=C2=A0In Zookeeper, they have specific set of custom exception= s like ZooKeeperException and so on. Do you have a specific reason for that= ?
=C2=A0
Thanks in advance!
=C2=A0
-Imesha
=C2=A0
--
Imesha Sudasingha
Undergraduate of Departm= ent of Computer Science and =C2=A0Engineering,
University of Moratuwa.<= /div>


=C2=A0
--
Imesha Sudasingha
Undergraduate of Departm= ent of Computer Science and =C2=A0Engineering,
University of Moratuwa.<= /div>

<= /div>
--001a114abda45970db0541e4e04e--