pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thejas M Nair (JIRA)" <j...@apache.org>
Subject [jira] Created: (PIG-1611) use enums for error code
Date Tue, 14 Sep 2010 19:37:33 GMT
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

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 -
throw new SchemaMergeException("Error in merging schema", 2124, PigException.BUG); 
throw new SchemaMergeException(SCHEMA_MERGE_EX, PigException.BUG); 


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.
SCHEMA_MERGE_EX("Error in merging schema");

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.

View raw message