Skip to content

Commit c776258

Browse files
committed
Show error details to the user
Implemented the feature #2
1 parent 6f7d323 commit c776258

8 files changed

+84
-26
lines changed

Web/Content/Site.css

+8-3
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ body {
126126
display: none;
127127
}
128128

129-
#findresult
129+
.otherwindow
130130
{
131131
border: 1px solid #ddd;
132132
border-bottom: none;
@@ -135,19 +135,24 @@ body {
135135
font-size: 0.9em;
136136
}
137137

138-
.findresultheader
138+
.otherwindowheader
139139
{
140140
padding: 7px 8px;
141141
background-color: #ddd;
142142
background-repeat: repeat-x;
143143
font-weight: bold;
144144
}
145145

146-
.findresultpane
146+
.otherwindowpane
147147
{
148148
height: 150px;
149149
}
150150

151+
.otherwindowpane .message {
152+
padding:7px 10px;
153+
}
154+
155+
151156
a.versionInfo, a.versionInfo:hover, a.versionInfo:active{
152157
color: #fff;
153158
}

Web/Models/ProjectClientStatus.cs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public enum ProjectStatus
1515

1616
public class ProjectClientStatus
1717
{
18+
public string DetailedMessage { get; set; }
1819

1920
public string Message { get; set; }
2021

Web/Scripts/App/Application.js

+37-14
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,32 @@ function projectInfoViewModel() {
163163

164164
};
165165

166+
/// Output window view model
167+
function outPutWindowViewModel(title, content) {
168+
var self = this;
169+
170+
self.show = ko.observable(true);
171+
self.title = title;
172+
self.content = content;
173+
174+
self.close = function () {
175+
self.show(false);
176+
}
177+
}
178+
179+
/// Find result window view model
180+
function findResultWindowViewModel(title, items) {
181+
var self = this;
182+
183+
self.show = ko.observable(true);
184+
self.title = title;
185+
self.items = items;
186+
187+
self.close = function () {
188+
self.show(false);
189+
}
190+
}
191+
166192
/// Application level view model class
167193
function appViewModel() {
168194
var self = this;
@@ -173,17 +199,19 @@ function appViewModel() {
173199
self.projectIsActive = ko.observable();
174200
self.projectStatus = ko.observable();
175201
self.findResult = ko.observable();
176-
self.showFindResultWindow = ko.observable(false);
177-
self.findResultWindowTitle = ko.observable();
202+
self.output = ko.observable();
178203

179204
self.projectHub = $.connection.projectHub;
180205

181206
self.projectHub.projectStatus = function (data) {
182-
if (data) {
183-
// If completed
184-
if (data.Status == 2) {
207+
if (data) {
208+
if (data.Status == 2) { // If completed
185209
self.projectStatus('');
186-
} else {
210+
} else if (data.Status == 3) { // Error
211+
self.projectStatus(data.Message);
212+
self.output(new outPutWindowViewModel(data.Message, data.DetailedMessage));
213+
}
214+
else {
187215
self.projectStatus(data.Message);
188216
}
189217
}
@@ -195,15 +223,11 @@ function appViewModel() {
195223
}
196224
};
197225

198-
self.closeFindReferenceWindow = function () {
199-
self.showFindResultWindow(false);
200-
};
201-
202226
self.findReferences = function (kind, text, position) {
203227
var project = self.project();
204228
var currentFilePath = project.file().path;
205-
var findReferencesUrl = '/api/solution/findreferences';
206-
self.findResultWindowTitle('Find result for "' + text + '"');
229+
var findReferencesUrl = '/api/solution/findreferences';
230+
207231

208232
$.post(findReferencesUrl,
209233
{
@@ -215,8 +239,7 @@ function appViewModel() {
215239
kind: kind
216240
},
217241
function (result) {
218-
self.findResult({ items: result });
219-
self.showFindResultWindow(true);
242+
self.findResult(new findResultWindowViewModel('Find result for "' + text + '"', result));
220243
}
221244
);
222245
};

Web/Services/DefaultSourceCodeOpeningProgressListener.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public void OnProjectLoaded()
5050
}
5151

5252

53-
public void OnProjectLoadingError()
53+
public void OnProjectLoadingError(string message)
5454
{
55-
this.Caller.projectStatus(new ProjectClientStatus { Status = ProjectStatus.Error, Message = "An error has occured while loading the project." });
55+
this.Caller.projectStatus(new ProjectClientStatus { Status = ProjectStatus.Error, Message = "An error has occured while loading the project.", DetailedMessage = message });
5656
}
5757

5858

Web/Services/GitHub/GitHubSourceCodeProviderService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ public ProjectItem GetContent(string username, string project, string path, ISou
105105
}
106106
});
107107

108-
openingProgressListener.OnProjectLoadingError();
108+
openingProgressListener.OnProjectLoadingError(ex.Message + Environment.NewLine + ex.StackTrace);
109109
this.logger.Error(ex, "Path too long exception {0} from project {1}/{2} ", path, username, project);
110110
}
111111
catch (Exception ex)
112112
{
113-
openingProgressListener.OnProjectLoadingError();
113+
openingProgressListener.OnProjectLoadingError(ex.Message + Environment.NewLine + ex.StackTrace);
114114
this.logger.Error(ex, "An error has occured while getting the content for path {0} from project {1}/{2} ", path, username, project);
115115
}
116116

Web/Services/ISourceCodeOpeningProgress.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface ISourceCodeOpeningProgress
2525

2626
void OnProjectPreparing();
2727

28-
void OnProjectLoadingError();
28+
void OnProjectLoadingError(string message);
2929

3030
void OnBuildingWorkspace();
3131
}

Web/Views/Home/Index.cshtml

+18-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@
8181
</table>
8282
</div>
8383
</div>
84-
<div data-bind="with: $root.findResult, visible: $root.showFindResultWindow" id="findresult" class="dockrow">
85-
<button class="close" data-bind="click: $root.closeFindReferenceWindow">&times;</button>
86-
<div class="findresultheader"><span data-bind="text: $root.findResultWindowTitle"></span></div>
87-
<div class="findresultpane container stylishscrollbar scroll-x scroll-y">
84+
<!-- ko with: $root.findResult -->
85+
<div data-bind="visible: show" class="otherwindow dockrow">
86+
<button class="close" data-bind="click: close">&times;</button>
87+
<div class="otherwindowheader"><span data-bind="text: title"></span></div>
88+
<div class="otherwindowpane container stylishscrollbar scroll-x scroll-y">
8889
<table class="table">
8990
<thead>
9091
<tr>
@@ -105,6 +106,19 @@
105106
</table>
106107
</div>
107108
</div>
109+
<!-- /ko -->
110+
<!-- ko with: $root.output -->
111+
<div data-bind="visible: show" class="otherwindow dockrow">
112+
<button class="close" data-bind="click: close">&times;</button>
113+
<div class="otherwindowheader"><span data-bind="text: title"></span></div>
114+
<div class="otherwindowpane container stylishscrollbar scroll-x scroll-y">
115+
<div data-bind="text: content" class="message">
116+
117+
</div>
118+
</div>
119+
</div>
120+
<!-- /ko -->
121+
108122
<div class="statusbar dockrow" data-bind="text: $root.projectStatus">
109123
</div>
110124
</div>

Web/Web.Debug.config

+15
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,19 @@
1717
<system.web>
1818
<customErrors mode="Off" xdt:Transform="Replace" />
1919
</system.web>
20+
<log4net xdt:Transform="Replace">
21+
<appender name="LeAppender" type="log4net.Appender.LeAppender, LeLog4net">
22+
<Key value="LOGENTRIES_ACCOUNT_KEY" />
23+
<Location value="LOGENTRIES_LOCATION" />
24+
<Debug value="true" />
25+
<Ssl value="false" />
26+
<layout type="log4net.Layout.PatternLayout">
27+
<param name="ConversionPattern" value="%d{ddd MMM dd HH:mm:ss zzz yyyy} %logger %: %level%, %m" />
28+
</layout>
29+
</appender>
30+
<root>
31+
<level value="ALL" />
32+
<appender-ref ref="LeAppender" />
33+
</root>
34+
</log4net>
2035
</configuration>

0 commit comments

Comments
 (0)