Add additional optional param to core.error

This commit is contained in:
Ryan Ghadimi
2025-03-27 17:03:39 +00:00
parent 930c890727
commit 1959adefa3
6 changed files with 267 additions and 15 deletions

View File

@@ -1,5 +1,8 @@
# @actions/core Releases
### 1.12.0
- Adds optional functionality to `core.error` to allow for the logging of stack traces.
### 1.11.1
- Fix uses of `crypto.randomUUID` on Node 18 and earlier [#1842](https://github.com/actions/toolkit/pull/1842)

View File

@@ -1,12 +1,12 @@
{
"name": "@actions/core",
"version": "1.11.1",
"version": "1.12.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@actions/core",
"version": "1.11.1",
"version": "1.12.0",
"license": "MIT",
"dependencies": {
"@actions/exec": "^1.1.1",

View File

@@ -1,6 +1,6 @@
{
"name": "@actions/core",
"version": "1.11.1",
"version": "1.12.0",
"description": "Actions core lib",
"keywords": [
"github",

View File

@@ -70,6 +70,13 @@ export interface AnnotationProperties {
endColumn?: number
}
export interface ErrorMessageProperties {
/**
* Whether to include the stack trace in the error message. Defaults to false.
*/
withStackTrace?: boolean
}
//-----------------------------------------------------------------------
// Variables
//-----------------------------------------------------------------------
@@ -274,12 +281,16 @@ export function debug(message: string): void {
*/
export function error(
message: string | Error,
properties: AnnotationProperties = {}
properties: AnnotationProperties & ErrorMessageProperties = {}
): void {
if (typeof message === 'string') {
issueCommand('error', toCommandProperties(properties), message)
return
}
issueCommand(
'error',
toCommandProperties(properties),
message instanceof Error ? message.toString() : message
properties.withStackTrace ? message.stack : message.toString()
)
}