You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got the following panic when I forget to add a = to a shortcode call, this can be reproduced with the shortcode: {{ youtube(id="dQw4w9WgXcQ", autoplay) }}.
I would expect a nice error message rather than a hard panic in this situation.
This happens because you split on the arguments and assume they will have two parts inside parse_shortcode. But parse_shortcode does not return an error to elegantly handle the error case.
thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', /checkout/src/liballoc/vec.rs:1551:10
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at /checkout/src/libstd/sys_common/backtrace.rs:68
2: std::panicking::default_hook::{{closure}}
at /checkout/src/libstd/sys_common/backtrace.rs:57
at /checkout/src/libstd/panicking.rs:381
3: std::panicking::default_hook
at /checkout/src/libstd/panicking.rs:397
4: std::panicking::rust_panic_with_hook
at /checkout/src/libstd/panicking.rs:577
5: std::panicking::begin_panic
at /checkout/src/libstd/panicking.rs:538
6: std::panicking::begin_panic_fmt
at /checkout/src/libstd/panicking.rs:522
7: rust_begin_unwind
at /checkout/src/libstd/panicking.rs:498
8: core::panicking::panic_fmt
at /checkout/src/libcore/panicking.rs:71
9: core::panicking::panic_bounds_check
at /checkout/src/libcore/panicking.rs:58
10: <alloc::vec::Vec<T> as core::ops::index::Index<usize>>::index
at /checkout/src/liballoc/vec.rs:1551
11: rendering::short_code::parse_shortcode
at components/rendering/src/short_code.rs:59
12: rendering::markdown::markdown_to_html::{{closure}}
at components/rendering/src/markdown.rs:138
13: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once
at /checkout/src/libcore/ops/function.rs:271
14: <core::option::Option<T>>::map
at /checkout/src/libcore/option.rs:398
15: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next
at /checkout/src/libcore/iter/mod.rs:1251
16: <pulldown_cmark::html::Ctx<'b, I>>::run
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/pulldown-cmark-0.1.0/src/html.rs:54
17: pulldown_cmark::html::push_html
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/pulldown-cmark-0.1.0/src/html.rs:283
18: rendering::markdown::markdown_to_html
at components/rendering/src/markdown.rs:290
19: content::page::Page::render_markdown
at components/content/src/page.rs:152
20: site::Site::render_markdown::{{closure}}
at components/site/src/lib.rs:248
21: <rayon::iter::map::MapFolder<'f, C, F> as rayon::iter::plumbing::Folder<T>>::consume
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/map.rs:218
22: rayon::iter::plumbing::Folder::consume_iter
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/plumbing.rs:84
23: rayon::iter::plumbing::Producer::fold_with
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/plumbing.rs:48
24: rayon::iter::plumbing::bridge_producer_consumer::helper
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/plumbing.rs:277
25: rayon::iter::plumbing::bridge_producer_consumer
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/plumbing.rs:250
26: <rayon::iter::plumbing::bridge::Callback<C> as rayon::iter::plumbing::ProducerCallback<I>>::callback
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/plumbing.rs:240
27: <rayon::vec::IntoIter<T> as rayon::iter::IndexedParallelIterator>::with_producer
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/vec.rs:63
28: rayon::iter::plumbing::bridge
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/plumbing.rs:223
29: <rayon::vec::IntoIter<T> as rayon::iter::ParallelIterator>::drive_unindexed
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/vec.rs:30
30: <rayon::collections::hash_map::IterMut<'a, K, V> as rayon::iter::ParallelIterator>::drive_unindexed
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/delegate.rs:30
31: <rayon::iter::map::Map<I, F> as rayon::iter::ParallelIterator>::drive_unindexed
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/map.rs:52
32: <rayon::iter::fold::Fold<I, ID, F> as rayon::iter::ParallelIterator>::drive_unindexed
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/fold.rs:56
33: rayon::iter::reduce::reduce
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/reduce.rs:14
34: rayon::iter::ParallelIterator::reduce
at /home/mdaffin/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/rayon-0.9.0/src/iter/mod.rs:353
35: site::Site::render_markdown
at components/site/src/lib.rs:245
36: site::Site::load
at components/site/src/lib.rs:220
37: gutenberg::cmd::serve::create_new_site
at src/cmd/serve.rs:96
38: gutenberg::cmd::serve::serve
at src/cmd/serve.rs:106
39: gutenberg::main
at src/main.rs:62
40: __rust_maybe_catch_panic
at /checkout/src/libpanic_unwind/lib.rs:101
41: std::rt::lang_start
at /checkout/src/libstd/panicking.rs:459
at /checkout/src/libstd/panic.rs:365
at /checkout/src/libstd/rt.rs:58
42: main
43: __libc_start_main
44: _start
The text was updated successfully, but these errors were encountered:
Woops.
The markdown rendering (including shortcodes, see #165) will be rewritten for the next major version which should be soonish, I'll add that to the test cases
I got the following panic when I forget to add a
=
to a shortcode call, this can be reproduced with the shortcode:{{ youtube(id="dQw4w9WgXcQ", autoplay) }}
.I would expect a nice error message rather than a hard panic in this situation.
This happens because you split on the arguments and assume they will have two parts inside
parse_shortcode
. Butparse_shortcode
does not return an error to elegantly handle the error case.The text was updated successfully, but these errors were encountered: