Skip to content

Commit

Permalink
Report context error if user-supplied group expression is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
David Berry committed Jan 7, 2013
1 parent fefabf8 commit c43c7e2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
22 changes: 20 additions & 2 deletions libraries/grp/grp_group.f
Expand Up @@ -132,6 +132,7 @@ SUBROUTINE GRP_GROUP( PARAM, IGRP1, IGRP2, SIZE, ADDED, FLAG,
* Global Constants:
INCLUDE 'SAE_PAR' ! Standard SAE constants
INCLUDE 'PAR_ERR' ! PAR error constants
INCLUDE 'DAT_ERR' ! DAT error constants
INCLUDE 'GRP_CONST' ! GRP private constants.
INCLUDE 'GRP_PAR' ! GRP public constants.

Expand Down Expand Up @@ -240,12 +241,29 @@ SUBROUTINE GRP_GROUP( PARAM, IGRP1, IGRP2, SIZE, ADDED, FLAG,
: 'GRP_GROUP: Aborted attempt to associate a group expression'//
: ' with the %^P parameter.', STATUS )

* If any other error occurred, add a context message.
* If the parameter request was aborted, annul the error and re-report
* it with a more friendly message.
ELSE IF ( STATUS .EQ. PAR__ABORT ) THEN
CALL ERR_ANNUL( STATUS )
STATUS = PAR__ABORT
CALL MSG_SETC( 'P', PARAM )
CALL ERR_REP( 'GRP_GROUP_ERR3',
: 'GRP_GROUP: Aborted attempt to associate a group expression'//
: ' with the %^P parameter.', STATUS )

* If the value was truncated add a suitable context message.
ELSE IF( STATUS .EQ. DAT__TRUNC ) THEN
CALL MSG_SETC( 'P', PARAM )
CALL ERR_REP( 'GRP_GROUP_ERR6', 'The list of valuess '//
: 'supplied for parameter %^P was too long.',
: STATUS )

* If any other error occurred, add a general context message.
ELSE IF( STATUS .NE. SAI__OK ) THEN
CALL MSG_SETC( 'P', PARAM )
CALL ERR_REP( 'GRP_GROUP_ERR4',
: 'GRP_GROUP: Unable to associate a group of names with'//
: ' parameter %^P', STATUS )
: ' parameter ''%^P''', STATUS )
END IF

* If an error has occurred, set SIZE to the initial group size. If this
Expand Down
10 changes: 9 additions & 1 deletion libraries/ndg/ndg_assoc.f
Expand Up @@ -184,6 +184,7 @@ SUBROUTINE NDG_ASSOC( PARAM, VERB, IGRP, SIZE, FLAG, STATUS )
INCLUDE 'SAE_PAR' ! Standard SAE constants
INCLUDE 'GRP_PAR' ! GRP constants.
INCLUDE 'GRP_ERR' ! GRP error constants.
INCLUDE 'DAT_ERR' ! DAT error constants.
INCLUDE 'PAR_ERR' ! Parameter system error constants.
INCLUDE 'NDG_ERR' ! NDG error constants.

Expand Down Expand Up @@ -434,7 +435,14 @@ SUBROUTINE NDG_ASSOC( PARAM, VERB, IGRP, SIZE, FLAG, STATUS )
: 'associate a group of NDFs with parameter ^P.',
: STATUS )

* If any other error occurred, add a context message.
* If the value was truncated add a suitable context message.
ELSE IF( STATUS .EQ. DAT__TRUNC ) THEN
CALL MSG_SETC( 'P', PARAM )
CALL ERR_REP( 'NDG_ASSOC_ERR6', 'The list of NDF names '//
: 'supplied for parameter ''%^P'' was too long.',
: STATUS )

* If any other error occurred, add a general context message.
ELSE IF( STATUS .NE. SAI__OK ) THEN
CALL MSG_SETC( 'P', PARAM )
CALL ERR_REP( 'NDG_ASSOC_ERR5', 'Unable to associate a group'//
Expand Down
8 changes: 8 additions & 0 deletions libraries/ndg/ndg_creat.f
Expand Up @@ -149,6 +149,7 @@ SUBROUTINE NDG_CREAT( PARAM, IGRP0, IGRP, SIZE, FLAG, STATUS )
INCLUDE 'SAE_PAR' ! Standard SAE constants
INCLUDE 'GRP_PAR' ! GRP constants.
INCLUDE 'PAR_ERR' ! Parameter system error constants.
INCLUDE 'DAT_ERR' ! DAT error constants.

* Arguments Given:
CHARACTER PARAM*(*)
Expand Down Expand Up @@ -326,6 +327,13 @@ SUBROUTINE NDG_CREAT( PARAM, IGRP0, IGRP, SIZE, FLAG, STATUS )
: 'associate a group of data sets with '//
: 'parameter %^P.', STATUS )

* If the value was truncated add a suitable context message.
ELSE IF( STATUS .EQ. DAT__TRUNC ) THEN
CALL MSG_SETC( 'P', PARAM )
CALL ERR_REP( 'NDG_CREAT_ERR5', 'The list of NDF names '//
: 'supplied for parameter ''%^P'' was too long.',
: STATUS )

* If any other error occurred, add a context message.
ELSE IF( STATUS .NE. SAI__OK ) THEN
CALL MSG_SETC( 'P', PARAM )
Expand Down

0 comments on commit c43c7e2

Please sign in to comment.