Home | History | Annotate | Download | only in opengl
      1 /*
      2  * Copyright (C) 2007 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.opengl;
     18 
     19 /**
     20  * An exception class for OpenGL errors.
     21  *
     22  */
     23 @SuppressWarnings("serial")
     24 public class GLException extends RuntimeException {
     25     public GLException(final int error) {
     26         super(getErrorString(error));
     27         mError = error;
     28     }
     29 
     30     public GLException(final int error, final String string) {
     31         super(string);
     32         mError = error;
     33     }
     34 
     35     private static String getErrorString(int error) {
     36         String errorString = GLU.gluErrorString(error);
     37         if ( errorString == null ) {
     38             errorString = "Unknown error 0x" + Integer.toHexString(error);
     39         }
     40         return errorString;
     41     }
     42 
     43     int getError() {
     44         return mError;
     45     }
     46 
     47     private final int mError;
     48 }
     49 
     50