Project

General

Profile

Actions

Patch #39207

closed

Replace `YAML.load` with `YAML.load_file` in locales.rake and improve error reporting for invalid YAML files

Added by Go MAEDA 6 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

The attached patch replaces YAML.load with YAML.load_file in lib/tasks/locales.rake and improves the error message when `rake locales` fail to parse a translation file.

Suppose config/locales/tr.yml is not a valid YAML file and rake locales raises an error. As shown in the example below, after the improvement, the name of the file containing the problem will be displayed instead of "<unknown>", making it easier to identify which file contains the problem.

Before:

Updating file ./config/locales/tr.yml
rake aborted!
Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 7 column 3

After:

Updating file ./config/locales/tr.yml
rake aborted!
Psych::SyntaxError: (./config/locales/tr.yml): did not find expected key while parsing a block mapping at line 7 column 3


Files

use_yaml_load_file.patch (1.13 KB) use_yaml_load_file.patch Go MAEDA, 2023-10-20 03:26
Actions #1

Updated by Go MAEDA 6 months ago

  • Subject changed from Use YAML.load_file instead of YAML.load to improve the error message of `rake locales` to Replace `YAML.load` with `YAML.load_file` in locales.rake and improve error reporting for invalid YAML files
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Target version set to 5.1.0

Committed the change in r22356.

Actions

Also available in: Atom PDF