Skip to content

Commit

Permalink
added error msg to assembler page
Browse files Browse the repository at this point in the history
  • Loading branch information
rbaker26 committed May 9, 2020
1 parent a18616a commit cb1b556
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
10 changes: 9 additions & 1 deletion SAP1EMU.WebApp/Controllers/AssemblerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ public class AssemblerController : ControllerBase
[HttpPost]
public ActionResult Post([FromBody] List<string> codeList)
{
return Ok(SAP1EMU.Assembler.Assemble.ParseFileContents(codeList));
try
{
return Ok(SAP1EMU.Assembler.Assemble.ParseFileContents(codeList));

}
catch (Exception e)
{
return BadRequest(e.Message + " " + e.InnerException.Message);
}
}

//// PUT: api/Assembler/5
Expand Down
28 changes: 14 additions & 14 deletions SAP1EMU.WebApp/Controllers/CodeAreaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ public class CodeAreaController : Controller
{
List<string> Code = new List<string>();

[HttpPost]
[ActionName("AssembleCode")]
public ActionResult<string> PostAssembleCode(CodeAreaModel codeAreaModel)
{
try
{
List<string> binary = Assemble.ParseFileContents(new List<string>(codeAreaModel.CodeList.Split("\n")));
return new ActionResult<string>(binary.ToString());
}
catch (Exception e)
{
return BadRequest(e.ToString());
}
}
//[HttpPost]
//[ActionName("AssembleCode")]
//public ActionResult<string> PostAssembleCode(CodeAreaModel codeAreaModel)
//{
// try
// {
// List<string> binary = Assemble.ParseFileContents(new List<string>(codeAreaModel.CodeList.Split("\n")));
// return new ActionResult<string>(binary.ToString());
// }
// catch (Exception e)
// {
// return BadRequest(e.ToString());
// }
//}



Expand Down
9 changes: 5 additions & 4 deletions SAP1EMU.WebApp/Views/Home/Assembler.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div class="row">
<div class="column1">
<h4>Assembler Output</h4>
<code class="assembler-out">example error@*<br />*@</code>
<code class="assembler-out" id="assembler-out"><br /></code>
</div>
<div></div> @*This blank div is req to trick the row::after or else the margins get screwed up*@
</div>
Expand Down Expand Up @@ -95,15 +95,16 @@ function AssembleCode(btnClicked)
console.log(data.toString());
console.log(data.toString().replace(/,/g ,'\n'));
$('#assembler-out').html('<br />');
bin_editor.setValue(data.toString().replace(/,/g ,'\n'));
return data;
},
error: function() {
alert('Error occured');
error: function (request, status, error) {
bin_editor.setValue("");
$('#assembler-out').html(request.responseText);
}
});
Expand Down

0 comments on commit cb1b556

Please sign in to comment.