﻿(function() {
    "use strict";

    var app = angular
        .module("productManagement",
        [
            "common.services"
            , "productResourceMock"
            , "ui.router"
            , "ui.mask"
            , "ui.bootstrap"
            , "angularCharts"
        ]);

    app.config(["$stateProvider"
                , "$urlRouterProvider",
                function ($stateProvider, $urlRouterProvider) {
                    $urlRouterProvider.otherwise("/");
                    $stateProvider
                        .state("home", {
                            url: "/",
                            templateUrl: "app/welcomeView.html"
                        })
                        .state("productList", {
                            url: "/products",
                            templateUrl: "app/products/productListView.html",
                            controller: "productListController as vm"
                        })
                        .state("productEdit", {
                            "abstract": true,
                            url: "/products/edit/:productId",
                            templateUrl: "app/products/productEditView.html",
                            controller: "productEditController as vm",
                            resolve: {
                                productResource: "productResource",
                                product: function (productResource, $stateParams) {
                                    var productId = $stateParams.productId;;
                                    return productResource.get({
                                        productId: productId
                                    }).$promise;
                                }
                            }
                        })
                        .state("productEdit.info", {
                            url: "/info",
                            templateUrl: "app/products/productEditInfoView.html"
                        })
                        .state("productEdit.price", {
                            url: "/price",
                            templateUrl: "app/products/productEditPriceView.html"
                        })
                        .state("productEdit.tags", {
                            url: "/tags",
                            templateUrl: "app/products/productEditTagsView.html"
                        })
                        .state("productDetail", {
                            url: "/products/:productId",
                            templateUrl: "app/products/productDetailView.html",
                            controller: "productDetailController as vm",
                            resolve: {
                                productResource: "productResource",
                                product: function(productResource, $stateParams) {
                                    var productId = $stateParams.productId;;
                                    return productResource.get({
                                        productId: productId
                                    }).$promise;
                                }
                            }
                        })
                        .state("priceAnalytics", {
                            url: "/priceAnalytics",
                            templateUrl: "app/prices/priceAnalyticsView.html",
                            controller: "PriceAnalyticsController",
                            resolve: {
                                productResource: "productResource",
                                products: function (productResource) {
                                    return productResource.query().$promise;
                                }
                            }
                        });
                }
    ]);

})();
@@ -284,16 +284,502 @@
    %5D);%0A%0A
+    app.config(function ($provide) %7B%0A        $provide.decorator(%22$exceptionHandler%22,%0A            %5B%22$delegate%22,%0A                function ($delegate) %7B%0A                    return function (exception, cause) %7B%0A                        exception.message = %22Please contact the Help Desk! %5Cn Message: %22 + exception.message;%0A                        $delegate(exception, cause);%0A                        alert(exception.message);%0A                    %7D;%0A                %7D%0A            %5D);%0A    %7D);%0A%0A
     app.
@@ -4173,16 +4173,573 @@
 e.query(
+function (response) %7B%0A                                        // no code needed for success%0A                                    %7D, function (response) %7B%0A                                        if (response.status == 404) %7B%0A                                            alert(%22Error accessing resource: %22 + response.config.method + %22 %22 + response.config.url);%0A                                        %7D else %7B%0A                                            alert(response.statusText);%0A                                        %7D%0A                                    %7D
 ).$promi

Add global exception handler and handle failure on promises