[erlang-bugs] Incorrect or misleading inets/http_server error message

Ingela Anderton Andin ingela@REDACTED
Wed Jul 30 08:35:44 CEST 2008


Hi Edwin,

well I suppose it is a little too much of a question of how you define 
type, and maybe your reasoning is more the common way to reason than 
mine. I think of "type" in a quite abstract way.  But I do not want to 
argue on what is more right or wrong, I think it is fair to choose 
another  wording  that  will be more clear to
all.  I suggest  {invalid_option, {non_existing, 
{document_root,"/tmp/htdocs"}}}. How do you feel about that?

Regards - Ingela Erlang/OTP, Ericsson

Edwin Fine wrote:
> Thanks, Ingela, your solution looks good, but I find it still a little 
> bit misleading. You see, what was provided was actually a directory 
> (in string format). The fact that the directory does not exist has 
> nothing to do with its type, really. What it has to do with is 
> validation. Maybe wrong_type would read better as validation_failed? 
> That covers both type checks and existence checks and any other kind 
> of checks of this sort that may come up in future.
>
> Regards,
> Edwin
>
> On Tue, Jul 29, 2008 at 5:15 AM, Ingela Anderton Andin 
> <ingela@REDACTED <mailto:ingela@REDACTED>> wrote:
>
>     Hi Edwin!
>
>     Well yes in this particular case it becomes a bit confusing I
>     agree.  It is a type check that has fail but this is obviously
>     a special case of failure so I changed it so it will become
>     *{wrong_type, {non_existing, document_root,"/tmp/htdocs"}}.
>     The type check acctualy checks if  "/tmp/htdocs" is a directory
>     and not only that it is a string on the correct format. So the
>     type here is "directory"
>     and not "string". But yes I can see that people might get
>     confused. I think this will be the best solution removing the
>     wrong_type in this case
>     will make the code cluttered of special cases in more than one
>     place, now I just handle the special case where it appeares and
>     the higer level code does not need to care about such details, and
>     also it is logical type error, the given parameter was not a valid
>     directory.
>
>     Regards - Ingela Erlang/OTP, Ericsson
>
>
>     *Edwin Fine wrote:
>
>         Taking the example out of the document at
>         http://www.erlang.org/doc/apps/inets/http_server.html:
>
>         2> {ok, Pid} = inets:start(httpd, [{port, 0},
>         2>       {server_name,"httpd_test"}, {server_root,"/tmp"},
>         2>       {document_root,"/tmp/htdocs"}, {bind_address,
>         "localhost"}]).
>
>         =ERROR REPORT==== 30-Jun-2008::17:47:18 ===
>         Failed initiating web server:
>         undefined
>         *{wrong_type,{document_root,"/tmp/htdocs"}}*
>
>         ** exception error: no match of right hand side value
>         {error,{shutdown,{child,undefined,
>                                                                      
>                        {httpd_instance_sup,{0,0,0,0,0,0,0,1},59104},
>                                                                      
>                        {httpd_instance_sup,start_link,
>                                                                      
>                                            [[{port,59104},
>                                                                      
>                                            
>          {bind_address,{0,0,0,0,0,0,0,1}},
>                                                                      
>                                              {server_name,"httpd_test"},
>                                                                      
>                                              {server_root,"/tmp"},
>                                                                      
>                                            
>          {document_root,"/tmp/htdocs"}],
>                                                                      
>                                             15000,
>                                                                      
>                                             {<0.50.0>,#Port<0.126>},
>                                                                      
>                                             []]},
>                                                                      
>                        permanent,infinity,supervisor,
>                                                                      
>                        [httpd_instance_sup]}}}
>
>         The actual problem was that the "/tmp/htdocs" directory did
>         not exist. I find having an error message of undefined
>         *{wrong_type,{document_root,"/tmp/htdocs"}} *to be very
>         misleading. I read it as "the value corresponding to
>         document_root [i.e. "/tmp/htdocs", of type string] is of the
>         wrong type". If not a string, what should it be, I wondered?
>
>         When I created the directory and tried again, the message went
>         away. I would have expected to see something like
>         {does_not_exist,{document_root,"/tmp/htdocs"}}.
>
>         3> {ok, Pid} = inets:start(httpd, [{port, 0},                
>                3>       {server_name,"httpd_test"}, {server_root,"/tmp"},
>         3>       {document_root,"/tmp/htdocs"}, {bind_address,
>         "localhost"}]).
>         {ok,<0.58.0>}
>         4>
>
>         Regards,
>         Edwin Fine
>         -- 
>         The great enemy of the truth is very often not the lie --
>         deliberate, contrived and dishonest, but the myth, persistent,
>         persuasive, and unrealistic. Belief in myths allows the
>         comfort of opinion without the discomfort of thought.
>         John F. Kennedy 35th president of US 1961-1963 (1917 - 1963)
>         ------------------------------------------------------------------------
>
>         _______________________________________________
>         erlang-bugs mailing list
>         erlang-bugs@REDACTED <mailto:erlang-bugs@REDACTED>
>         http://www.erlang.org/mailman/listinfo/erlang-bugs
>
>
>
>
>
>
> -- 
> For every expert there is an equal and opposite expert - Arthur C. Clarke




More information about the erlang-bugs mailing list