From a524836c94d4ddd3aa3520b5418b380d4c9f4e1a Mon Sep 17 00:00:00 2001 From: KtorZ Date: Fri, 6 Oct 2023 14:45:25 +0200 Subject: [PATCH] Add compiler version & system information to panic error message So that we stop constantly asking people about it. --- CHANGELOG.md | 1 + crates/aiken-project/src/config.rs | 12 ++++++++++++ crates/aiken/src/main.rs | 8 +++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5d5689d..7b39ab3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - **aiken-project**: The `plutus.json` blueprint now contains a `compiler.name` and `compiler.version` fields. +- **aiken-prokect**: Add compiler and system information to panic error report. ### Changed diff --git a/crates/aiken-project/src/config.rs b/crates/aiken-project/src/config.rs index b6925963..9dcaf734 100644 --- a/crates/aiken-project/src/config.rs +++ b/crates/aiken-project/src/config.rs @@ -132,3 +132,15 @@ pub fn compiler_version(include_commit_hash: bool) -> String { format!("v{}", built_info::PKG_VERSION_MAJOR,) } } + +pub fn compiler_info() -> String { + format!( + r#" +Operating System: {} +Architecture: {} +Version: {}"#, + built_info::CFG_OS, + built_info::CFG_TARGET_ARCH, + compiler_version(true), + ) +} diff --git a/crates/aiken/src/main.rs b/crates/aiken/src/main.rs index fdfd708d..777766c8 100644 --- a/crates/aiken/src/main.rs +++ b/crates/aiken/src/main.rs @@ -4,6 +4,7 @@ use aiken::cmd::{ packages::{self, add}, tx, uplc, Cmd, }; +use aiken_project::{config, pretty}; use owo_colors::OwoColorize; @@ -54,18 +55,19 @@ fn panic_handler() { let error_message = indoc::formatdoc! { r#"{fatal} - Whoops! You found a bug in the Aiken compiler. Please report this error at https://github.com/aiken-lang/aiken/issues/new. In your bug report please provide the information below and if possible the code that produced it. + {info} - {location}{message}"#, + {location}{message}"#, + info = config::compiler_info(), fatal = "aiken::fatal::error".red().bold(), location = location.purple(), }; - println!("{error_message}") + println!("\n{}", pretty::indent(&error_message, 3)); })); }