Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ namespace Microsoft.Azure.Quantum.Exceptions
{
public class AzureQuantumException : Exception
{
public AzureQuantumException(string message = "An exception related to the Azure quantum service or storage occurred.")
public AzureQuantumException()
: base("An exception related to the Azure quantum occurred.")
{
}

public AzureQuantumException(string message)
: base(message)
{
}

public AzureQuantumException(string message, Exception inner)
: base(message, inner)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ namespace Microsoft.Quantum.Simulation.Common.Exceptions
{
public class QuantumProcessorTranslationException : Exception
{
public QuantumProcessorTranslationException(string message = "An exception occurred while performing a translation on a quantum processor.")
public QuantumProcessorTranslationException()
: base("An exception occurred while performing a translation on a quantum processor.")
{
}

public QuantumProcessorTranslationException(string message)
: base(message)
{
}

public QuantumProcessorTranslationException(string message, Exception inner)
: base(message, inner)
{
}
}
}
34 changes: 31 additions & 3 deletions src/Simulation/EntryPointDriver/Azure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using System.CommandLine.Parsing;
using System.Threading.Tasks;
using Microsoft.Azure.Quantum;
using Microsoft.Azure.Quantum.Exceptions;
using Microsoft.Quantum.Runtime;
using Microsoft.Quantum.Simulation.Common.Exceptions;
using static Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Driver;

namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver
Expand Down Expand Up @@ -54,9 +56,35 @@ internal static async Task<int> Submit<TIn, TOut>(
}
else
{
var job = await machine.SubmitAsync(
entryPoint.Info, input, new SubmissionContext { Shots = settings.Shots });
DisplayJob(job, settings.Output);
try
{
var job = await machine.SubmitAsync(
entryPoint.Info, input, new SubmissionContext { Shots = settings.Shots });
DisplayJob(job, settings.Output);
}
catch (AzureQuantumException azureQuantumEx)
{
DisplayWithColor(
ConsoleColor.Red,
Console.Error,
"Something went wrong when submitting the program to the Azure Quantum service.");

Console.Error.WriteLine();
Console.Error.WriteLine(azureQuantumEx.Message);
return 1;
}
catch (QuantumProcessorTranslationException translationEx)
{
DisplayWithColor(
ConsoleColor.Red,
Console.Error,
"Something went wrong when performing translation to the intermediate representation used by the target quantum machine.");

Console.Error.WriteLine();
Console.Error.WriteLine(translationEx.Message);
return 1;
}

return 0;
}
}
Expand Down