build
build copied to clipboard
Allow plugins to report error details
Plugins can report errors with:
utils.build.failBuild('error message')
or:
// `error` helps keep the inner error's stack trace
utils.build.failBuild('error message', { error: innerError })
Same with utils.build.failPlugin()
or utils.build.cancelBuild()
.
The error is printed in the build logs. It is also sent to the API, so that it is shown by the front-end in the "deploy summary". The way this is currently done:
- The
title
isPlugin "netlify-plugin-example" failed
- The
summary
(body) is the error message - The
text
(collapsible content) is the error stack trace and error location (In event onBuild
)
However, when the error message is long, some users might want some of it to go under text
(the collapsible content) instead.
One way to provide this capability could be to add a details
option to the utils.build.*()
methods:
utils.build.failBuild('error message', { details: 'long details' })
This can be implemented solely inside Netlify Build (API and front-end already have everything needed for this feature).
This was suggested by @erezrokah when working on netlify-plugin-lighthouse
.
Note: we already provide a utils.status.show()
method, but this is only for plugin success information to be shown in the deploy summary. As opposed to utils.build.*()
, it does not stop the plugin execution nor have any error/exception behavior.
Use case is writing a detailed error message to the logs (for the lighthouse plugin - specific audits that failed), while a short error message to the UI summary (for the lighthouse plugin - specific categories that failed).
This issue has been automatically marked as stale because it has not had activity in 1 year. It will be closed in 14 days if no further activity occurs. Thanks!
This issue was closed because it had no activity for over 1 year.