pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ashutosh Chauhan (JIRA)" <j...@apache.org>
Subject [jira] Commented: (PIG-1611) use enums for error code
Date Thu, 23 Dec 2010 20:32:45 GMT

    [ https://issues.apache.org/jira/browse/PIG-1611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12974724#action_12974724
] 

Ashutosh Chauhan commented on PIG-1611:
---------------------------------------

Instead of creating new Exceptions (like UnionOnSchemaSetException) for all possible exception
types, will it make sense just to have one Exception type (PigException) or may be few of
top level one like (FrontEndException, BackEndException etc) and containing an enum ErrorType
within it. ErrorType will contain the message and code for error. That way a new error will
translate just into a new entry in ErrorType. No duplication. We adopted this approach in
Howl and till now its working fine for us. 
Whether to have only one top level PigException or have a few and then arrange them in an
Exception hierarchy (like PigException extends IOException, FrontException extends PigException,
BackendException extends PigException) I dont have a strong opinion. But I do find that such
Exception hierarchy too complicated for usage without really giving any benefit and was atleast
partially responsible for bugs previously (PIG-1531, PIG-1598 etc.)
I do have a strong opinion against doing this only partially and then leave a way to deal
with errors both ways old style exception code Vs new style enum based. Whenever we move to
this new way of doing exception handling it should be complete and from there on there should
only be one way of dealing with Exceptions in Pig, otherwise that will result in more confusion.

Ref:
https://github.com/yahoo/howl/blob/howl/howl/src/java/org/apache/hadoop/hive/howl/common/ErrorType.java
https://github.com/yahoo/howl/blob/howl/howl/src/java/org/apache/hadoop/hive/howl/common/HowlException.java


> use enums for error code
> ------------------------
>
>                 Key: PIG-1611
>                 URL: https://issues.apache.org/jira/browse/PIG-1611
>             Project: Pig
>          Issue Type: Sub-task
>            Reporter: Thejas M Nair
>             Fix For: 0.9.0
>
>         Attachments: PIG-1611.1.patch
>
>
> Pig code is using integer constants for error code, and the value of the error code is
reserved using http://wiki.apache.org/pig/PigErrorHandlingFunctionalSpecification .
> This process is cumbersome and error prone.
> It will be better to use enum values instead. The enum value can contain the error message
and encapsulate the error code. 
> For example -
> {code}
> Replace 
> throw new SchemaMergeException("Error in merging schema", 2124, PigException.BUG); 
> with
> throw new SchemaMergeException(SCHEMA_MERGE_EX, PigException.BUG); 
> {code}
> Where SCHEMA_MERGE_EX belongs to a error codes enum. We can use the ordinal value of
the enum and an offset to determine the error code. 
> The error code will be passed through the constructor of the enum.
> {code}
> SCHEMA_MERGE_EX("Error in merging schema");
> {code}
> For documentation, the error code and error messages can be dumped using code that uses
the enum error code class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message