skins/AknSkins/sdcsrc/SDCException.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Exception class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "SDCGlobals.h"
       
    20 #include "SDCException.h"
       
    21 
       
    22 #include <string.h>
       
    23 #include <stdio.h>
       
    24 
       
    25 //////////////////////////////////////////////////////////////////////
       
    26 // Construction/Destruction
       
    27 //////////////////////////////////////////////////////////////////////
       
    28 
       
    29 CSDCException::CSDCException()
       
    30     {
       
    31     iType = ESDCUnknownError;
       
    32     strcpy( iDescription, "No additional information" );
       
    33     }
       
    34 
       
    35 CSDCException::CSDCException( TSDCExceptionType aType, const char* aDescription )
       
    36     {
       
    37     iType = aType;
       
    38     strcpy( iDescription, aDescription );
       
    39     }
       
    40 
       
    41 CSDCException::~CSDCException()
       
    42     {
       
    43     }
       
    44 
       
    45 //////////////////////////////////////////////////////////////////////
       
    46 // Construction/Destruction
       
    47 //////////////////////////////////////////////////////////////////////
       
    48 
       
    49 void CSDCException::Print()
       
    50     {
       
    51     char buf[1024];
       
    52 
       
    53     if( gInput.iLineNumber > -1 )
       
    54         {
       
    55         sprintf(buf, "An exception occured (when parsing line %i):\n  ", gInput.iLineNumber );
       
    56         }
       
    57     else
       
    58         {
       
    59         sprintf(buf, "An exception occured:\n  " );
       
    60         }
       
    61 
       
    62     fprintf(stderr, buf);
       
    63     printf(buf);
       
    64 
       
    65     switch( iType )
       
    66         {
       
    67         case ESDCUnknownError:
       
    68             sprintf(buf, "Unknown error\n"); break;
       
    69         case ESDCFileOpenError:
       
    70             sprintf(buf, "Error while opening a file\n"); break;
       
    71         case ESDCPrematureEOIError:
       
    72             sprintf(buf, "Premature end of input\n"); break;
       
    73         case ESDCSeekError:
       
    74             sprintf(buf, "Seek operation failed\n"); break;
       
    75         case ESDCParseError:
       
    76             sprintf(buf, "Parse error\n"); break;
       
    77         case ESDCContentError:
       
    78             sprintf(buf, "Error in skin content\n"); break;
       
    79         default:
       
    80             sprintf(buf, "Internal error, missing description\n"); break;
       
    81         }
       
    82 
       
    83     fprintf(stderr, buf);
       
    84     printf(buf);
       
    85 
       
    86     sprintf(buf, "  %s\n", iDescription);
       
    87 
       
    88     fprintf(stderr, buf);
       
    89     printf(buf);
       
    90     }
       
    91 
       
    92 // End of file