Is this a bug?

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

Is this a bug?

Carl Ketterling
Before I report this as a bug, I'd like to know from someone more
experienced if they agree.

As I read it, if an error is reported (error_code), that error is useful
until the next time a database action is attempted.  So, if one database
action returns an error, and the next database is successful, the
error_code should be reset to 0.

In the following code, the database action is successful, but the output
shows error_code doesn't change:

<?LassoScript

    output('\nError: ' + error_code);
    error_seterrorcode:5555;
    output('\nError: ' + error_code);

    inline:
        -database='Products',
        -table='products list',
        'category'='Software',
        -search;
        output('\nFound: ' + found_count);
        output('\nError: ' + error_code);
   
    /inline;

    output('\nError: ' + error_code);

?>


OUTPUT:

Error: 0
Error: 5555
Found: 18
Error: 5555
Error: 5555


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Is this a bug?

Jolle Carlestam-3
In any kind of question like this it is always important to send along platform information.
Especially revealing if it's Lasso 8 or 9.

HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Is this a bug?

Carl Ketterling
I'm sorry ... I know that, and I meant to:

Lasso 9.2.4 running on Mac OS X Server v10.7.5
connecting to
FileMaker Server Advanced v11 running on Mac OS X Server v10.6.8

Carl

In response to this text from Jolle Carlestam
([hidden email]) sent on Tuesday, November 6, 2012 at 11:33
PM (+0000):

>In any kind of question like this it is always important to send along
>platform information.
>Especially revealing if it's Lasso 8 or 9.
>
>HDB
>Jolle
>#############################################################
>This message is sent to you because you are subscribed to
>  the mailing list Lasso
>[hidden email]
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Is this a bug?

Jolle Carlestam-3
In reply to this post by Carl Ketterling
7 nov 2012 kl. 09:29 skrev Carl Ketterling <[hidden email]>:

> As I read it, if an error is reported (error_code), that error is useful
> until the next time a database action is attempted.  So, if one database
> action returns an error, and the next database is successful, the
> error_code should be reset to 0.

I suggest you read up on the error methods in Lasso 9 reference. Especially how to master the error_push, error_pop and error_reset methods.

Here're some examples on how to use error_reset.

local(messages = array)

inline(-database = 'information_schema', -sql = 'SELECT * from information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {

        #messages -> insert(error_code = error_msg)
}

inline(-database = 'information_schema', -sql = 'SELECT * from not_there.CHARACTER_SETS WHERE MAXLEN > 3') => {

        #messages -> insert(error_code = error_msg)
}

inline(-database = 'information_schema', -sql = 'SELECT * from information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {

        #messages -> insert(error_code = error_msg)
}

#messages -> join('<br />')

-> (0 = No error)
(1146 = Table 'not_there.character_sets' doesn't exist)
(1146 = Table 'not_there.character_sets' doesn't exist) // your problem, the error status from the prev inline is still there.

The solution:
local(messages = array)

inline(-database = 'information_schema', -sql = 'SELECT * from information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {

        #messages -> insert(error_code = error_msg)
}
error_reset // will reset error_status
inline(-database = 'information_schema', -sql = 'SELECT * from not_there.CHARACTER_SETS WHERE MAXLEN > 3') => {

        #messages -> insert(error_code = error_msg)
}
error_reset // will reset error_status
inline(-database = 'information_schema', -sql = 'SELECT * from information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {

        #messages -> insert(error_code = error_msg)
}

#messages -> join('<br />')

-> (0 = No error)
(1146 = Table 'not_there.character_sets' doesn't exist)
(0 = No error) // look see, error status as you're expecting it
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Is this a bug?

Jolle Carlestam-3
7 nov 2012 kl. 10:25 skrev Jolle Carlestam <[hidden email]>:

> I suggest you read up on the error methods in Lasso 9 reference. Especially how to master the error_push, error_pop and error_reset methods.

Answer part two, error_push and error_pop:

Here's another problem that might occur. You have a method, or type that contain code who's execution is dependent on errors that might have happened inside the method. But since there might have been an error triggered before the method was called the method will fail despite the error not being relevant for the method.

First code that does not work as you'd want it:
define mymethod => {

        /*
        Do some coding here that might produce an error
        */

        if(error_code) => {
                return 'Not working, got an error ' + error_msg
        }

        return 'I am so happy! It is working!'
}

local(messages = array)

inline(-database = 'information_schema', -sql = 'SELECT * from information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {
}
mymethod
#messages -> insert(error_code = error_msg)
'<hr />'
error_reset

inline(-database = 'information_schema', -sql = 'SELECT * from not_there.CHARACTER_SETS WHERE MAXLEN > 3') => {
}
mymethod
'<hr />'
#messages -> insert(error_code = error_msg)
error_reset

inline(-database = 'information_schema', -sql = 'SELECT * from information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {
}
#messages -> insert(error_code = error_msg)

#messages -> join('<br />')

-> I am so happy! It is working!
Not working, got an error Table 'not_there.character_sets' doesn't exist // See, this is due to an error that happened outside the method and it's not what we want t ohappen
(0 = No error)
(1146 = Table 'not_there.character_sets' doesn't exist)
(0 = No error)


Let's try with error_push and error_pop inside the method:
define mymethod => {
        error_push
        handle => { error_pop }

        /*
        Do some coding here that might produce an error
        */

        if(error_code) => {
                return 'Not working, got an error ' + error_msg
        }

        return 'I am so happy! It is working!'
}

local(messages = array)

inline(-database = 'information_schema', -sql = 'SELECT * from information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {
}
mymethod
#messages -> insert(error_code = error_msg)
'<hr />'
error_reset

inline(-database = 'information_schema', -sql = 'SELECT * from not_there.CHARACTER_SETS WHERE MAXLEN > 3') => {
}
mymethod
'<hr />'
#messages -> insert(error_code = error_msg)
error_reset

inline(-database = 'information_schema', -sql = 'SELECT * from information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {
}
#messages -> insert(error_code = error_msg)

#messages -> join('<br />')

-> I am so happy! It is working!
I am so happy! It is working! // The method works as we want it
(0 = No error)
(1146 = Table 'not_there.character_sets' doesn't exist) // We get this reported as it should despite the error being triggered before the method call thanks to the error_pop in the method
(0 = No error)


More to read on it:
http://www.lassosoft.com/lassoDocs/languageReference/obj/error_push
http://www.lassosoft.com/lassoDocs/languageReference/obj/error_pop

HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Is this a bug?

Carl Ketterling
In reply to this post by Jolle Carlestam-3
Jolle,

I really appreciate your trying to help me understand (and honestly, I
never understood the format "... => { ... } ", but that's a different
discussion altogether).  I have learned that I can use error_reset to
address the problem.

From http://www.lassosoft.com/lassoDocs/languageReference/obj/error_msg :
"The error code and message will remain until they are reset by another
method call."

In the past, any call to a database function would reset the error
codes.  In recent versions of Lasso, no errors were ever returned from
FileMaker databases, so even though I've kept error checking in my code,
it really made no sense.  In the current (Mac OS) version of Lasso, the
error is NOT reset using a database call.

My opinion is that this is a bug in the functionality, but I wanted some
insight from someone with more experience.  At what point did this
change (since I went directly from v6 to v9)?  And was it an intentional
change or an oversight?

I'll report it as a bug and let LassoSoft decide what to do.

Carl



In response to this text from Jolle Carlestam
([hidden email]) sent on Wednesday, November 7, 2012 at 12:25
AM (+0000):

>7 nov 2012 kl. 09:29 skrev Carl Ketterling <[hidden email]>:
>
>> As I read it, if an error is reported (error_code), that error is useful
>> until the next time a database action is attempted.  So, if one database
>> action returns an error, and the next database is successful, the
>> error_code should be reset to 0.
>
>I suggest you read up on the error methods in Lasso 9 reference.
>Especially how to master the error_push, error_pop and error_reset methods.
>
>Here're some examples on how to use error_reset.
>
>local(messages = array)
>
>inline(-database = 'information_schema', -sql = 'SELECT * from
>information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {
>
> #messages -> insert(error_code = error_msg)
>}
>
>inline(-database = 'information_schema', -sql = 'SELECT * from
>not_there.CHARACTER_SETS WHERE MAXLEN > 3') => {
>
> #messages -> insert(error_code = error_msg)
>}
>
>inline(-database = 'information_schema', -sql = 'SELECT * from
>information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {
>
> #messages -> insert(error_code = error_msg)
>}
>
>#messages -> join('<br />')
>
>-> (0 = No error)
>(1146 = Table 'not_there.character_sets' doesn't exist)
>(1146 = Table 'not_there.character_sets' doesn't exist) // your problem,
>the error status from the prev inline is still there.
>
>The solution:
>local(messages = array)
>
>inline(-database = 'information_schema', -sql = 'SELECT * from
>information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {
>
> #messages -> insert(error_code = error_msg)
>}
>error_reset // will reset error_status
>inline(-database = 'information_schema', -sql = 'SELECT * from
>not_there.CHARACTER_SETS WHERE MAXLEN > 3') => {
>
> #messages -> insert(error_code = error_msg)
>}
>error_reset // will reset error_status
>inline(-database = 'information_schema', -sql = 'SELECT * from
>information_schema.CHARACTER_SETS WHERE MAXLEN > 3') => {
>
> #messages -> insert(error_code = error_msg)
>}
>
>#messages -> join('<br />')
>
>-> (0 = No error)
>(1146 = Table 'not_there.character_sets' doesn't exist)
>(0 = No error) // look see, error status as you're expecting it
>#############################################################
>This message is sent to you because you are subscribed to
>  the mailing list Lasso
>[hidden email]
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>