Want to cause a build error for bad input - jekyll

Here is a my blog post:
---
last-medical-review: 2022-12-03
---
Some post
And then there is a layout that reads this front matter and renders the page. All pages need to have the medical review date specified. (And there are plenty of other rules.)
Is it possible to trigger some error conditionally if this front matter element is missing? I am hoping the build can fail as a fatal error.

Assuming there is a layout somewhere that does something like this:
<p>Last medical review: {{ page.last-medical-review }}</p>
then you can add the following to your _config.yml:
liquid:
strict_variables: true
which will result in a build error like this if last-medical-review isn't defined in the front matter:
Liquid Exception: Liquid error (line 7): undefined variable minima in /tmp/jekylltest/_layouts/post.html
------------------------------------------------
Jekyll 4.3.1 Please append `--trace` to the `serve` command
for any additional information or backtrace.
------------------------------------------------

Related

Polymer 3 error - how to configure Rollup --inlineDynamicImport option

I am getting the following error after adding dynamic imports (required for the use case) when trying to build using polymer tools:
info: Clearing build/ directory...
error: Promise rejection: Error: Failed to bundle. Rollup generated 2 chunks or assets. Expected 1.
error: Error: Failed to bundle. Rollup generated 2 chunks or assets. Expected 1.
at Es6Rewriter.<anonymous> (/home/suared/localdev/nodespace/ui/node_modules/polymer-cli/node_modules/polymer-bundler/lib/es6-rewriter.js:138:23)
at Generator.next (<anonymous>)
at fulfilled (/home/suared/localdev/nodespace/ui/node_modules/polymer-cli/node_modules/polymer-bundler/lib/es6-rewriter.js:4:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I found a potential solution in the Rollup docs and the web that referenced this problem being fixed when passing --inlineDynamicImports to the Rollup command. I have not found away to pass this as part of the build process, however. I tried this:
polymer build --auto-base-path --inlineDynamicImport
It reported the error that it is an unknown option. I also tried placing this in the polymer.json as part of the bundle config, unsuccessfully; it doesn't look like it is actually passed to Rollup:
"bundle": {
"inlineCss": true,
"inlineScripts": true,
"rewriteUrlsInTemplates": true,
"sourcemaps": true,
"stripComments": true,
"--inlineDynamicImport": true
}
What is the correct way to pass to the Polymer build tools the --inlineDynamicImport option so that I only get one file and therefore will avoid the "2 chunks" error?
If it helps others till I get a real answer, this workaround worked for me:
Local monkey patch/ update of the following file:
node_modules/polymer-cli/node_modules/polymer-bundler/lib/es6-rewriter.js:74
In the call that reads like the first line, manually add the configuration, leave the rest of the config as-is:
const rollupBundle = yield rollup_1.rollup({
input,
external,
onwarn: (warning) => { },
treeshake: this.bundler.treeshake,
inlineDynamicImports: true, ....(rest of existing command
Any assistance on the right way using the build tools is welcome/ appreciated.
Thanks!
David

CODED UI TESTS: is there a way to add a warning in html report?

In my Coded UI Test project, I need to check if few Labels or Messages are consistent with the context. But those checks are not critical if not consistent and I need to output them only as warnings.
Note that I'm using nested ordered tests to use only one global ordered test with vstest.console.exe and get in one shot the overall test coverage report.
Till now I was creating assertions to check those consistencies, but an assertion failure leads to Test failure, then to ordered test failure and then to playback stop.
I tried to change Playback.PlaybackSettings.ContinueOnError value before and after the assertion: this works as I expect as the assertion is well reported as a warning in the html report file. But whatever, it causes the ordered test to stop and then my global ordered test chaining to fail...
I tried to use TestContext.WriteLine too instead of creating assert, but it seems that this is not output in the html report.
So my question is:
is there any way to create an assertion only as a Warning that will be output in the html report file and that doesn't lead to a test failure?
Thanks a lot for any answer and help on this ;)
So I got my solution with developping my own Warning Engine to integrate Warnings in test report, 'cause I found no existing solution for that with the current Coded UI Test Assertion engine.
I'll try to take some time to post generic parts of the code structure with comments translated in english (we're french so default comments are french for now...), but here are the main step lines :
Create a template based on the UITestActionLog.html original file
report structure of Coded UI Test engine, with only the start
bloc and the javascript functions and CSS declarations in it.
Create an assertion class with a main function to manage insertion
of Warning html bloc in the html report first created from the template.
Then create custom assert functions to call the main function
whereever on runtime, and custom Stopwatch to inject elapsed time in
the report ('cause I could'nt found a way to get back the elapsed
time directly from the Coded UI Test engine).
That's it.
Just a proposition as a way to do it, maybe not the best one but it worked for me. I'll try to take time to put blocl codes to be clearer on it.

NetSuite Advanced PDF / HTML error: "Parse exception during template merging. Unexpected end of file reached."

I have created a complex Advanced PDF / HTML Template using freemarker. When I make no changes and attempt to save the template, the template saves with no errors. When I add a new field to the template through the UI or even simple HTML "Test" and then try to save, I get the following error:
"Parse exception during template merging.
com.netledger.templates.TemplateServiceException: Parse exception
during template merging. freemarker.core.ParseException: Unexpected
end of file reached."
If I proceed and save anyway, the printed PDF gives the same error and displays:
"The template stored was invalid". What does this error mean and how can I resolve it?
It means that you have some FreeMarker construct in the template that weren't closed. Like, and ${ without the matching }, or an <#if ...> without the matching </#if>.
BTW, usually the error message also tells what wasn't closed. Perhaps you are using an old FreeMarker version where error message quality was lower. You may try to copy-paste the template into http://freemarker-online.kenshoo.com/ to see what a more recent version says.

Errors within nested views always show a vague error message. Can it be made more verbose?

I'm using View Composers and nested views in general to build my layouts, and whenever any PHP errors are encountered, it always shows a generic Method Illuminate\View\View::__toString() must not throw an exception error message. Is there a way for it to show the actual error without having to guess what it is? Or is this limitation of PHP impossible to get around?
The error log also shows the same vague message, so that isn't a solution either.

How to print the line nuber that caused an exception in Java

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_exception_methods.htm#exception_common_methods This site shows that getLineNumber was included, but I am not able to use it. Thanks
( I am trying to locate a Null Pointer Exception )
a NullPointerException stack trace includes a line number, so the exception should print it.
It's unclear what you're asking, please show some code.
getLineNumber() and getStackTraceString() should include the line number (among others). Check https://developer.salesforce.com/forums?id=906F00000008xc4IAA for sample message.
As for "how to print" - there's a try-catch example. Either simply push it at System.debug() or (if it's visualforce context) you can add a pagemessage.
You can also go to setup -> debug log, attach the tracking to your user and retry the action? You'll see the stacktrace and other goodies, line numbers next to the names of called methods...