1616#include " qasm3/Exception.hpp"
1717#include " qasm3/Importer.hpp"
1818
19+ #include < exception>
1920#include < llvm/Support/CommandLine.h>
2021#include < llvm/Support/InitLLVM.h>
2122#include < llvm/Support/SourceMgr.h>
@@ -83,9 +84,11 @@ loadQASMFile(StringRef filename, mlir::MLIRContext* context) {
8384 // Translate to MLIR dialect QC
8485 return mlir::translateQuantumComputationToQC (context, qc);
8586 } catch (const qasm3::CompilerError& exception) {
86- errs () << " Failed to parse QASM file: '" << exception.what () << " '\n " ;
87+ errs () << " Failed to parse QASM file '" << filename << " ': '"
88+ << exception.what () << " '\n " ;
8789 } catch (const std::exception& exception) {
88- errs () << " Failed to load QASM file: '" << exception.what () << " '\n " ;
90+ errs () << " Failed to load QASM file '" << filename << " ': '"
91+ << exception.what () << " '\n " ;
8992 }
9093 return nullptr ;
9194}
@@ -99,7 +102,7 @@ loadMLIRFile(StringRef filename, mlir::MLIRContext* context) {
99102 std::string errorMessage;
100103 auto file = mlir::openInputFile (filename, &errorMessage);
101104 if (!file) {
102- errs () << errorMessage << " \n " ;
105+ errs () << " Failed to load file ' " << filename << " ': ' " << errorMessage << " ' \n " ;
103106 return nullptr ;
104107 }
105108
@@ -157,7 +160,6 @@ int main(int argc, char** argv) {
157160 module = loadMLIRFile (INPUT_FILENAME, &context);
158161 }
159162 if (!module ) {
160- errs () << " Failed to load input file: " << INPUT_FILENAME << " \n " ;
161163 return 1 ;
162164 }
163165
0 commit comments