Skip to content

Commit 0a3167e

Browse files
committed
#442 : Minor changes related to console error message output.
1 parent e033235 commit 0a3167e

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

Cognifide.PowerShell/Client/Applications/PowerShellConsole.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,15 @@ public override void HandleMessage(Message message)
7777
var job =
7878
JobManager.GetJob(PowerShellWebService.GetJobId(message.Arguments["guid"], message.Arguments["handle"]));
7979

80-
IMessage iMessage;
81-
while (job.MessageQueue.GetMessage(out iMessage))
80+
if (job != null)
8281
{
83-
iMessage.Execute();
82+
IMessage iMessage;
83+
while (job.MessageQueue.GetMessage(out iMessage))
84+
{
85+
iMessage.Execute();
86+
}
8487
}
88+
8589
if (message.Arguments.AllKeys.Contains("finished") && message.Arguments["finished"] == "true")
8690
{
8791
ProgressOverlay.Visible = false;

Cognifide.PowerShell/Commandlets/Security/AccountIdentity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public AccountIdentity(string name)
2222

2323
if (!Regex.IsMatch(account, @"^\w[\w\s.\\_-]*$", RegexOptions.Compiled))
2424
{
25-
throw new ArgumentException(String.Format("The name '{0}' contains illegal characters.\n\nThe name can only contain the following characters: a-z, 0-9, periods, dashes, underscores, and spaces.", account), account);
25+
throw new ArgumentException(String.Format("The name '{0}' is improperly formatted.\n\nThe name can only contain the following characters: a-z, 0-9, periods, dashes, underscores, backslashes, and spaces.", name), "name");
2626
}
2727

2828
Domain = domain;

Cognifide.PowerShell/sitecore modules/PowerShell/Services/PowerShellWebService.asmx.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ public object ExecuteCommand(string guid, string command, string stringFormat)
121121
new Result
122122
{
123123
status = StatusError,
124-
result = output +
125-
"\r\n[[;#f00;#000]Ooops, something went wrong... Do you need assistance?]\r\n" +
126-
"[[;#f00;#000]Send an email with the stack trace to adam@najmanowicz.com or contact me on Twitter @AdamNaj]\r\n\r\n" +
127-
session.GetExceptionString(ex, ScriptSession.ExceptionStringFormat.Console) + "\r\n",
124+
result = output + session.GetExceptionString(ex, ScriptSession.ExceptionStringFormat.Console) + "\r\n" +
125+
"\r\n[[;#f00;#000]Uh oh, looks like the command you ran is invalid or something else went wrong. Is it something we should know about?]\r\n" +
126+
"[[;#f00;#000]Please submit a support ticket here https://github.com/SitecorePowerShell/Console/ with error details, screenshots, and anything else that might help.]\r\n\r\n" +
127+
"[[;#f00;#000]We also have a user guide here http://sitecorepowershell.gitbooks.io/sitecore-powershell-extensions/.]\r\n\r\n",
128128
prompt = string.Format("PS {0}>", session.CurrentLocation)
129129
});
130130
}
@@ -164,11 +164,16 @@ protected void RunJob(ScriptSession session, string command)
164164
if (job != null)
165165
{
166166
job.Status.Failed = true;
167-
job.Status.Messages.Add("Ooops, something went wrong... Do you need assistance?");
168-
job.Status.Messages.Add(
169-
"Send an email with the stack trace to adam@najmanowicz.com or contact me on Twitter @AdamNaj");
170-
job.Status.Messages.Add(session.GetExceptionString(ex));
171-
job.Status.LogException(ex);
167+
168+
var exceptionMessage = session.GetExceptionString(ex);
169+
if (job.Options.WriteToLog)
170+
{
171+
Log.Error(exceptionMessage, this);
172+
}
173+
job.Status.Messages.Add(exceptionMessage);
174+
job.Status.Messages.Add("Uh oh, looks like the command you ran is invalid or something else went wrong. Is it something we should know about?");
175+
job.Status.Messages.Add("Please submit a support ticket here https://github.com/SitecorePowerShell/Console/ with error details, screenshots, and anything else that might help.");
176+
job.Status.Messages.Add("We also have a user guide here http://sitecorepowershell.gitbooks.io/sitecore-powershell-extensions/.");
172177
}
173178
else
174179
{

0 commit comments

Comments
 (0)