Author: olga Date: Fri Feb 22 11:48:45 2008 New Revision: 630302 URL: http://svn.apache.org/viewvc?rev=630302&view=rev Log: PIG-109: improved error handling
Modified: incubator/pig/trunk/CHANGES.txt incubator/pig/trunk/src/org/apache/pig/EvalFunc.java incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigOutputFormat.java incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigSplit.java incubator/pig/trunk/src/org/apache/pig/impl/PigContext.java incubator/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOLoad.java Modified: incubator/pig/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/incubator/pig/trunk/CHANGES.txt?rev=630302&r1=630301&r2=630302&view=diff ============================================================================== --- incubator/pig/trunk/CHANGES.txt (original) +++ incubator/pig/trunk/CHANGES.txt Fri Feb 22 11:48:45 2008 @@ -120,3 +120,5 @@ PIG-46: abort processing on error for non-interactive mode (olston via olgan) + + PIG-109: improved exception handling (oae via olgan) Modified: incubator/pig/trunk/src/org/apache/pig/EvalFunc.java URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/EvalFunc.java?rev=630302&r1=630301&r2=630302&view=diff ============================================================================== --- incubator/pig/trunk/src/org/apache/pig/EvalFunc.java (original) +++ incubator/pig/trunk/src/org/apache/pig/EvalFunc.java Fri Feb 22 11:48:45 2008 @@ -93,13 +93,8 @@ private Type getReturnTypeFromSpec(String funcSpec){ - try{ - return ((EvalFunc)PigContext.instantiateFuncFromSpec(funcSpec)).getReturnType(); - }catch (IOException e){ - throw new RuntimeException(e); - }catch (ClassCastException e){ - throw new RuntimeException(funcSpec + " does not specify an eval func", e); - } + return ((EvalFunc) PigContext.instantiateFuncFromSpec(funcSpec)) + .getReturnType(); } public Type getReturnType(){ Modified: incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigOutputFormat.java URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigOutputFormat.java?rev=630302&r1=630301&r2=630302&view=diff ============================================================================== --- incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigOutputFormat.java (original) +++ incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigOutputFormat.java Fri Feb 22 11:48:45 2008 @@ -54,13 +54,7 @@ if (storeFunc.length() == 0) { store = new PigStorage(); } else { - try { store = (StoreFunc) PigContext.instantiateFuncFromSpec(storeFunc); - } catch (Exception e) { - RuntimeException re = new RuntimeException(e.getClass().getName() + ": " + e.getMessage()); - re.setStackTrace(e.getStackTrace()); - throw re; - } } String parentName = outputDir.getParent().getName(); int suffixStart = parentName.lastIndexOf('.'); Modified: incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigSplit.java URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigSplit.java?rev=630302&r1=630301&r2=630302&view=diff ============================================================================== --- incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigSplit.java (original) +++ incubator/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapreduceExec/PigSplit.java Fri Feb 22 11:48:45 2008 @@ -96,15 +96,10 @@ if (this.parser == null) { loader = new PigStorage(); } else { - try { - loader = (LoadFunc) PigContext.instantiateFuncFromSpec(this.parser); - }catch(Exception exp) { - throw new RuntimeException("can't instantiate " + parser, exp); - } + loader = (LoadFunc) PigContext.instantiateFuncFromSpec(this.parser); } return loader; } - public String[] getLocations() throws IOException { String hints[][] = fs.getFileCacheHints(file, start, length); Modified: incubator/pig/trunk/src/org/apache/pig/impl/PigContext.java URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/impl/PigContext.java?rev=630302&r1=630301&r2=630302&view=diff ============================================================================== --- incubator/pig/trunk/src/org/apache/pig/impl/PigContext.java (original) +++ incubator/pig/trunk/src/org/apache/pig/impl/PigContext.java Fri Feb 22 11:48:45 2008 @@ -403,7 +403,7 @@ } @SuppressWarnings("unchecked") - private static Object instantiateFunc(String className, String argString) throws IOException { + private static Object instantiateFunc(String className, String argString) { Object ret; List<String> args = parseArguments(argString); try{ @@ -419,12 +419,13 @@ ret = objClass.newInstance(); } }catch(Throwable e){ - throw WrappedIOException.wrap(e.getMessage(), e); + throw new RuntimeException("could not instantiate '" + className + + "' with arguments '" + args + "'", e); } return ret; } - public static Object instantiateFuncFromSpec(String funcSpec) throws IOException{ + public static Object instantiateFuncFromSpec(String funcSpec) { return instantiateFunc(getClassNameFromSpec(funcSpec), getArgStringFromSpec(funcSpec)); } Modified: incubator/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOLoad.java URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOLoad.java?rev=630302&r1=630301&r2=630302&view=diff ============================================================================== --- incubator/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOLoad.java (original) +++ incubator/pig/trunk/src/org/apache/pig/impl/logicalLayer/LOLoad.java Fri Feb 22 11:48:45 2008 @@ -47,30 +47,12 @@ FileSpec inputFileSpec) throws IOException, ParseException { super(opTable, scope, id); this.inputFileSpec = inputFileSpec; - try { - LoadFunc storageFunc = - (LoadFunc) PigContext.instantiateFuncFromSpec(inputFileSpec. - getFuncSpec()); - } catch(IOException e) { - Throwable cause = e.getCause(); - while (cause != null - && cause.getClass().getName() != - "java.lang.ClassNotFoundException") { - log.error("cause = " + cause.getClass().getName(), e); - cause = cause.getCause(); - } if (cause != null) { - ParseException pe = new ParseException("Load function " + - inputFileSpec.getFuncSpec() + - " not found"); - pe.initCause(e); - throw pe; - } else { - throw e; - } + + // check if we can instantiate load func + LoadFunc storageFunc = (LoadFunc) PigContext + .instantiateFuncFromSpec(inputFileSpec.getFuncSpec()); - } - - //TODO: Handle Schemas defined by Load Functions + // TODO: Handle Schemas defined by Load Functions schema = new TupleSchema(); }