 
   link = ($scope, element, attrs, controller) ->
 
+    ValidationError = () ->
+    ValidationError.prototype = Error.prototype;
 
     #Setting csLog
-    csLog.set($scope, "csWizard", true)
+    csLog.set($scope, "csWizard")
 
     $scope.loading = true
     $scope.errors = []
 
     $scope.setOptions = (resource, item, formMode, wizardMaxDepth, parent) ->
 
+      $scope.log("setOptions")
       panelDescriptor = {
         resource : resource
         item : item

    overriden_resource_descriptors = {}

    $scope.resource_descriptor = (panel) ->
      if overriden_resource_descriptors[panel.resource.descriptor.type]
        return overriden_resource_descriptors[panel.resource.descriptor.type]
      else

        $scope.panelStack[0].item = $scope.csWizardOptions['form-item']

    $scope.$watchCollection 'panelStack', (newPanelStack, oldPanelStack) ->

      if newPanelStack
        attrs.$set 'numberOfPanels', newPanelStack.length
        $scope.numberOfPanels = newPanelStack.length
      else
        $scope.log("NotPanelStack")

    # ===== LIFECYCLE EVENTS ==============================

