Best way to pass error from lib to screen

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

Best way to pass error from lib to screen

Peter D Bethke
Hello all,

I loaded the knop demo for 9 without adding the data source for the sample db and got a lasso error that I traced to a single line in /_library/lib_customer_list.inc:

// get list of records
        $d -> select($searchparams);

I’m assuming that the knop_database object is kacking on selecting from a database that’s not been initialized - but it did sort of mess with the shiny out of the box experience of knop running even if the database was not initialized.

Is there a method in knop_database that will let me check for connectivity before running the select method, and then if it returns no connectivity is there an error object that I can then pass a message to the index page warning users to add the datasource?

Something like:

if ($d->available);

        $d -> select($searchparams);

else;

        $error->(add: ‘Error: You need to RTFM and add the database first to run the demo properly);

/if;


Then, maybe in the html body:

if: $error->haserrors;

        $error->render;

else;

        …. knop list code here ...

/if;


Peter
--
#############################################################
This message is sent to you because you are subscribed to
the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
List archive http://lasso.2283332.n4.nabble.com/Knop-Framework-Discussion-f3157831.html
The Knop project and code is hosted at GitHub.
https://github.com/knop-project/knop
Reply | Threaded
Open this post in threaded view
|

Re: Best way to pass error from lib to screen

stevepiercy
The oncreate method of knop_database has an optional -validate,
which returns the standard error_code and error_msg if the
database is not available.

In the demo files, see index.lasso.  Errors can be shown using
the $message var or the ->trace method.

--steve


On 2/24/14 at 1:42 PM, [hidden email] (Peter D Bethke) pronounced:

>Hello all,
>
>I loaded the knop demo for 9 without adding the data source for
>the sample db and got a lasso error that I traced to a single
>line in /_library/lib_customer_list.inc:
>
>// get list of records
>$d -> select($searchparams);
>
>I’m assuming that the knop_database object is kacking on
>selecting from a database that’s not been initialized - but
>it did sort of mess with the shiny out of the box experience of
>knop running even if the database was not initialized.
>
>Is there a method in knop_database that will let me check for
>connectivity before running the select method, and then if it
>returns no connectivity is there an error object that I can
>then pass a message to the index page warning users to add the datasource?
>
>Something like:
>
>if ($d->available);
>
>$d -> select($searchparams);
>else;
>
>$error->(add: ‘Error: You need to RTFM and add the database
>first to run the demo properly);
>
>/if;
>
>
>Then, maybe in the html body:
>
>if: $error->haserrors;
>
>$error->render;
>
>else;
>
>…. knop list code here ...
>
>/if;
>
>
>Peter

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>


--
#############################################################
This message is sent to you because you are subscribed to
the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
List archive http://lasso.2283332.n4.nabble.com/Knop-Framework-Discussion-f3157831.html
The Knop project and code is hosted at GitHub.
https://github.com/knop-project/knop
Reply | Threaded
Open this post in threaded view
|

Re: Best way to pass error from lib to screen

Johan Solve-2
In reply to this post by Peter D Bethke
Make $error an array and just insert into it.
Replace $error -> haserror with $error -> size.


At 13.42 -0500 2014-02-24, Peter D Bethke wrote:

>Hello all,
>
>I loaded the knop demo for 9 without adding the data source for the sample db and got a lasso error that I traced to a single line in /_library/lib_customer_list.inc:
>
>// get list of records
> $d -> select($searchparams);
>
>I'm assuming that the knop_database object is kacking on selecting from a database that's not been initialized - but it did sort of mess with the shiny out of the box experience of knop running even if the database was not initialized.
>
>Is there a method in knop_database that will let me check for connectivity before running the select method, and then if it returns no connectivity is there an error object that I can then pass a message to the index page warning users to add the datasource?
>
>Something like:
>
>if ($d->available);
>
> $d -> select($searchparams);
>
>else;
>
> $error->(add: 'Error: You need to RTFM and add the database first to run the demo properly);
>
>/if;
>
>
>Then, maybe in the html body:
>
>if: $error->haserrors;
>
> $error->render;
>
>else;
>
> Š. knop list code here ...
>
>/if;
>
>
>Peter
>--
>#############################################################
>This message is sent to you because you are subscribed to
>the mailing list <[hidden email]>.
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>
>List archive http://lasso.2283332.n4.nabble.com/Knop-Framework-Discussion-f3157831.html
>The Knop project and code is hosted at GitHub.
>https://github.com/knop-project/knop


--
     Johan Sölve
     Web Developer
     Montania System AB
     http://www.montania.se

--
#############################################################
This message is sent to you because you are subscribed to
the mailing list <[hidden email]>.
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
List archive http://lasso.2283332.n4.nabble.com/Knop-Framework-Discussion-f3157831.html
The Knop project and code is hosted at GitHub.
https://github.com/knop-project/knop