Submitted by Anonymous (not verified) on Mon, 07/06/2015 - 00:00
Forums

Hi,

A customer has asked if it is possible to change the behaviour of IceBreak in the event of an error?

At present IceBreak displays the job log, can this be changed to show, for example, some form generic error screen with details on contacting their help desk?

Niels Liisberg

Mon, 07/06/2015 - 00:00

Hi,

Yes and it is easy to customize that behavior.

If you place an IceBreak program with the name of SVCDEFAULT in the applications root, then this program will be called whenever an error occurs i.e. if you need a better 404-file not found page then place it here.

I have attached the default source for SVCDEFAULT which is shipped in the admin server of IceBreak. This also illustrates why you see a joblog in development mode.

<%

H bnddir('ICEUTILITY')
/include qasphdr,iceutility
/*      -----------------------------------------------------------------------------
*       Default response:
*       You can copy this code and place iti into you application folder
*       with the name of SVCDEFAULT. You can use it for any default response Even implement
*       WEB-DAV etc.
*
*       This SVCDEFAUL2 is the fallback if you did not provide a SVCDEFAULT
*
*       compile - but modify for your server settings:
*
*       CRTICEPGM STMF('/udv/icebreak/admin/svcdefaul2.aspx') SVRID(SVCUDV)
* ----------------------------------------------------------------------------- */

var method   varchar(16)
var host     varchar(128)
var resource varchar(256)
var href     varchar(256)
var url      varchar(256)
var err      varchar(256)
var i        int(10)
var msgid    char(7)
/free
/*      -----------------------------------------------------------------------------
 Main
  ----------------------------------------------------------------------------- */
  *INRT = *ON;

  SetContentType('text/plain; charset=UTF-8');

  monitor;
          method = UpperCase(getServervar('REQUEST_METHOD'));
 on-error;
         setStatus ('405 ' + 'Invalid blank method');
                return;
     endmon;

 select;
         when method = 'OPTIONS';
                  exsr options;
 when method = 'GET'
 or method = 'POST'
  or method = 'HEAD';
                 exsr handleError;
         other;
          setStatus ('405 ' + 'Invalid method: ' + method);

 endsl;
//      -----------------------------------------------------------------------------
begsr options;

 // Force Microsoft to use DAV
 //setHeader('MS-Author-Via':'DAV');

 setHeader('Allow' :
         'OPTIONS, GET, HEAD, POST');
endsr;

// -------------------------------------------------------------------------------------------------
begsr handleError;

  // peek the resource (rcs) from the current URL
 url = lowerCase(getServerVar('REQUEST_URL'));
 if %scan ('favicon.ico':url) > 0;
          SetContentType('image/x-icon; charset=UTF-8');
          if ('' = include(
                   'favicon.ico' :
                 './system/images:./system/shared/images'
                  ));
                   return; // Return if no error
         endif;
  endif;

  // Only show joblog in development mode
 if getServerVar('server_job_mode') = '*DEVELOP';
          setMarker('joblog' :
                  '<iframe class="logframe" src="/system/dspjoblog.aspx" -
                         </iframe>'
          );
  else;
         setMarker('joblog' : '');
 endif;


  msgId = getLastError('*MSGID');

 if wordIx('CPF9802' : msgid : ',') > 0;
          setMarker('msg' :
                        '403 ' + getLastError('*MSGTXT')
                   + ' for ' +url
          );

          err = include(
                  '403.html' :
                  './Errors:./system/shared/Errors:./system/Errors'
         );

          if err > '';
                 exsr dftErrorDoc;
           endif;
          SetContentType('text/html; charset=UTF-8');
           setStatus ('403 Not authorized '
                  + url
                   + ' in server '
                   + getServerVar('SERVER_ID')
         );

  elseif wordIx('CPD0170,CPF9801' : msgid : ',') > 0 or msgid = ' '; // Blank is from 
Front end server => Not found

         setMarker('msg' :
                 '404 Not found - Error opening file or application '
                  + url
                 + ' No such path or directory.'
         );

          err = include(
                        '404.html' :
                  './Errors:./system/shared/Errors:./system/Errors'
         );

          if err > '';
                 exsr dftErrorDoc;
         endif;
          SetContentType('text/html; charset=UTF-8');
         setStatus ('404 Not found '
                   + url
                 + ' in server '
                 + getServerVar('SERVER_ID')
         );

  else;

         setMarker('msg' :
                   '500 ' + getLastError('*MSGTXT')
                  + ' for ' +url
          );

          err = include(
                  '500.html' :
                  './Errors:./system/shared/Errors:./system/Errors'
         );

          if err > '';
                 exsr dftErrorDoc;
         endif;
          SetContentType('text/html; charset=UTF-8');
         setStatus ('500 Internal error '
                  + url
                 + ' in server '
                 + getServerVar('SERVER_ID')
         );
  endif;
endsr;
// -------------------------------------------------------------------------------------------------
begsr dftErrorDoc;
%><!--#include file="./System/errors/404.html" --><%
endsr;
// -------------------------------------------------------------------------------------------------

 

Best regards,
Niels Liisberg