The file is either an unsupported format or has syntax errors.
Provide a more human-friendly error message rather than the default catch-all error with a status code.
* F_data_not if buffer is empty (buffer.used is 0).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
+ * F_end_not_eos If EOS was reached before the Content at depth 0 was fully terminated.
* F_end_not_group_eos if EOS was reached before the a group termination was reached.
* F_end_not_group_stop if stop point was reached before the a group termination was reached.
+ * F_end_not_nest_eos If EOS was reached before the Content at depth 1 or greater was fully terminated.
+ * F_end_not_nest_stop If stop point was reached before the Content at depth 1 or greater was fully terminated.
+ * F_end_not_stop If stop point was reached before the Content at depth 0 was fully terminated.
*
* F_interrupt (with error bit) if stopping due to an interrupt.
* F_parameter (with error bit) if a parameter is invalid.
if (F_status_is_error(main->setting.state.status)) {
if (F_status_set_fine(main->setting.state.status) == F_interrupt) return;
- fll_error_file_print(
- &main->program.error,
- F_status_set_fine(main->setting.state.status),
- macro_fss_read_f(fll_fss_basic_read),
- fll_error_file_flag_fallback_e,
- fss_read_file_identify(main->setting.range.start, main->setting.files),
- f_file_operation_process_s,
- fll_error_file_type_file_e
- );
+ // Handle knownable errors with more user-friendly messages.
+ switch (F_status_set_fine(main->setting.state.status)) {
+ case F_end_not_eos:
+ case F_end_not_group_eos:
+ case F_end_not_group_stop:
+ case F_end_not_nest_eos:
+ case F_end_not_nest_stop:
+ case F_end_not_stop:
+ fss_read_print_error_fss_end_early(&main->program.error, fss_read_file_identify(main->setting.range.start, main->setting.files));
+
+ break;
+
+ default:
+ fll_error_file_print(
+ &main->program.error,
+ F_status_set_fine(main->setting.state.status),
+ macro_fss_read_f(fll_fss_basic_read),
+ fll_error_file_flag_fallback_e,
+ fss_read_file_identify(main->setting.range.start, main->setting.files),
+ f_file_operation_process_s,
+ fll_error_file_type_file_e
+ );
+ }
return;
}
if (F_status_is_error(main->setting.state.status)) {
if (F_status_set_fine(main->setting.state.status) == F_interrupt) return;
- fll_error_file_print(
- &main->program.error,
- F_status_set_fine(main->setting.state.status),
- macro_fss_read_f(fll_fss_basic_list_read),
- fll_error_file_flag_fallback_e,
- fss_read_file_identify(main->setting.range.start, main->setting.files),
- f_file_operation_process_s,
- fll_error_file_type_file_e
- );
+ // Handle knownable errors with more user-friendly messages.
+ switch (F_status_set_fine(main->setting.state.status)) {
+ case F_end_not_eos:
+ case F_end_not_group_eos:
+ case F_end_not_group_stop:
+ case F_end_not_nest_eos:
+ case F_end_not_nest_stop:
+ case F_end_not_stop:
+ fss_read_print_error_fss_end_early(&main->program.error, fss_read_file_identify(main->setting.range.start, main->setting.files));
+
+ break;
+
+ default:
+ fll_error_file_print(
+ &main->program.error,
+ F_status_set_fine(main->setting.state.status),
+ macro_fss_read_f(fll_fss_basic_list_read),
+ fll_error_file_flag_fallback_e,
+ fss_read_file_identify(main->setting.range.start, main->setting.files),
+ f_file_operation_process_s,
+ fll_error_file_type_file_e
+ );
+ }
return;
}
if (F_status_is_error(main->setting.state.status)) {
if (F_status_set_fine(main->setting.state.status) == F_interrupt) return;
- fll_error_file_print(
- &main->program.error,
- F_status_set_fine(main->setting.state.status),
- macro_fss_read_f(fll_fss_embedded_list_read),
- fll_error_file_flag_fallback_e,
- fss_read_file_identify(main->setting.range.start, main->setting.files),
- f_file_operation_process_s,
- fll_error_file_type_file_e
- );
+ // Handle knownable errors with more user-friendly messages.
+ switch (F_status_set_fine(main->setting.state.status)) {
+ case F_end_not_eos:
+ case F_end_not_group_eos:
+ case F_end_not_group_stop:
+ case F_end_not_nest_eos:
+ case F_end_not_nest_stop:
+ case F_end_not_stop:
+ fss_read_print_error_fss_end_early(&main->program.error, fss_read_file_identify(main->setting.range.start, main->setting.files));
+
+ break;
+
+ default:
+ fll_error_file_print(
+ &main->program.error,
+ F_status_set_fine(main->setting.state.status),
+ macro_fss_read_f(fll_fss_embedded_list_read),
+ fll_error_file_flag_fallback_e,
+ fss_read_file_identify(main->setting.range.start, main->setting.files),
+ f_file_operation_process_s,
+ fll_error_file_type_file_e
+ );
+ }
return;
}
if (F_status_is_error(main->setting.state.status)) {
if (F_status_set_fine(main->setting.state.status) == F_interrupt) return;
- fll_error_file_print(
- &main->program.error,
- F_status_set_fine(main->setting.state.status),
- macro_fss_read_f(fll_fss_extended_read),
- fll_error_file_flag_fallback_e,
- fss_read_file_identify(main->setting.range.start, main->setting.files),
- f_file_operation_process_s,
- fll_error_file_type_file_e
- );
+ // Handle knownable errors with more user-friendly messages.
+ switch (F_status_set_fine(main->setting.state.status)) {
+ case F_end_not_eos:
+ case F_end_not_group_eos:
+ case F_end_not_group_stop:
+ case F_end_not_nest_eos:
+ case F_end_not_nest_stop:
+ case F_end_not_stop:
+ fss_read_print_error_fss_end_early(&main->program.error, fss_read_file_identify(main->setting.range.start, main->setting.files));
+
+ break;
+
+ default:
+ fll_error_file_print(
+ &main->program.error,
+ F_status_set_fine(main->setting.state.status),
+ macro_fss_read_f(fll_fss_extended_read),
+ fll_error_file_flag_fallback_e,
+ fss_read_file_identify(main->setting.range.start, main->setting.files),
+ f_file_operation_process_s,
+ fll_error_file_type_file_e
+ );
+ }
return;
}
if (F_status_is_error(main->setting.state.status)) {
if (F_status_set_fine(main->setting.state.status) == F_interrupt) return;
- fll_error_file_print(
- &main->program.error,
- F_status_set_fine(main->setting.state.status),
- macro_fss_read_f(fll_fss_extended_list_read),
- fll_error_file_flag_fallback_e,
- fss_read_file_identify(main->setting.range.start, main->setting.files),
- f_file_operation_process_s,
- fll_error_file_type_file_e
- );
+ // Handle knownable errors with more user-friendly messages.
+ switch (F_status_set_fine(main->setting.state.status)) {
+ case F_end_not_eos:
+ case F_end_not_group_eos:
+ case F_end_not_group_stop:
+ case F_end_not_nest_eos:
+ case F_end_not_nest_stop:
+ case F_end_not_stop:
+ fss_read_print_error_fss_end_early(&main->program.error, fss_read_file_identify(main->setting.range.start, main->setting.files));
+
+ break;
+
+ default:
+ fll_error_file_print(
+ &main->program.error,
+ F_status_set_fine(main->setting.state.status),
+ macro_fss_read_f(fll_fss_extended_list_read),
+ fll_error_file_flag_fallback_e,
+ fss_read_file_identify(main->setting.range.start, main->setting.files),
+ f_file_operation_process_s,
+ fll_error_file_type_file_e
+ );
+ }
return;
}
}
#endif // _di_fss_read_print_error_file_
+#ifndef _di_fss_read_print_error_fss_end_early_
+ f_status_t fss_read_print_error_fss_end_early(fl_print_t * const print, const f_string_static_t name) {
+
+ if (!print) return F_status_set_error(F_output_not);
+ if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not;
+
+ f_file_stream_lock(print->to);
+
+ fl_print_format("%[%QFailed to parse the file '%]", print->to, print->context, print->prefix, print->context);
+ fl_print_format(f_string_format_Q_single_s.string, print->to, print->notable, name, print->notable);
+ fl_print_format("%[' could not be parsed because the data is not in a supported format or has syntax errors.%]%r", print->to, print->context, print->context, f_string_eol_s);
+
+ f_file_stream_unlock(print->to);
+
+ return F_okay;
+ }
+#endif // _di_fss_read_print_error_fss_end_early_
+
#ifndef _di_fss_read_print_error_parameter_requires_message_
f_status_t fss_read_print_error_parameter_requires_message(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_string_static_t message) {
#endif // _di_fss_read_print_error_file_
/**
+ * Print file related error regarding that the data is not in a correct or valid format.
+ *
+ * @param print
+ * The output structure to print to.
+ *
+ * The print.custom is expected to be of type fss_read_main_t.
+ *
+ * This does not alter print.custom.setting.state.status.
+ * @param name
+ * The name of the file.
+ *
+ * @return
+ * F_okay on success.
+ * F_output_not on success, but no printing is performed.
+ *
+ * F_output_not (with error bit) if a parameter is NULL.
+ */
+#ifndef _di_fss_read_print_error_fss_end_early_
+ extern f_status_t fss_read_print_error_fss_end_early(fl_print_t * const print, const f_string_static_t name);
+#endif // _di_fss_read_print_error_fss_end_early_
+
+/**
* Print an error message about the parameter requires something that is explained by the message parameter.
*
* @param print