Added context-specific error management.

Added error codes to replace connectErrorCode.