Skip to content

Commit

Permalink
Refactor: log token replacement errors at TRACE instead of WARN (#1159)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm committed Jun 13, 2024
1 parent 72b1757 commit d4db60a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
31 changes: 20 additions & 11 deletions src/modules/candidateGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ChecksumBitmask } from '../types/files/fileChecksums.js';
import FileFactory from '../types/files/fileFactory.js';
import IndexedFiles from '../types/indexedFiles.js';
import Options from '../types/options.js';
import OutputFactory from '../types/outputFactory.js';
import OutputFactory, { OutputPath } from '../types/outputFactory.js';
import ReleaseCandidate from '../types/releaseCandidate.js';
import ROMWithFiles from '../types/romWithFiles.js';
import Module from './module.js';
Expand Down Expand Up @@ -201,10 +201,13 @@ export default class CandidateGenerator extends Module {

try {
const outputFile = await this.getOutputFile(dat, game, release, rom, inputFile);
if (outputFile === undefined) {
return [rom, undefined];
}
const romWithFiles = new ROMWithFiles(rom, inputFile, outputFile);
return [rom, romWithFiles];
} catch (error) {
this.progressBar.logWarn(`${dat.getNameShort()}: ${game.getName()}: ${error}`);
this.progressBar.logError(`${dat.getNameShort()}: ${game.getName()}: ${error}`);
return [rom, undefined];
}
}),
Expand Down Expand Up @@ -313,16 +316,22 @@ export default class CandidateGenerator extends Module {
release: Release | undefined,
rom: ROM,
inputFile: File,
): Promise<File> {
): Promise<File | undefined> {
// Determine the output file's path
const outputPathParsed = OutputFactory.getPath(
this.options,
dat,
game,
release,
rom,
inputFile,
);
let outputPathParsed: OutputPath;
try {
outputPathParsed = OutputFactory.getPath(
this.options,
dat,
game,
release,
rom,
inputFile,
);
} catch (error) {
this.progressBar.logTrace(`${dat.getNameShort()}: ${game.getName()}: ${error}`);
return undefined;
}
const outputFilePath = outputPathParsed.format();

// Determine the output CRC of the file
Expand Down
2 changes: 1 addition & 1 deletion src/types/outputFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface ParsedPathWithEntryPath extends ParsedPath {
/**
* A {@link ParsedPathWithEntryPath} that normalizes formatting across OSes.
*/
class OutputPath implements ParsedPathWithEntryPath {
export class OutputPath implements ParsedPathWithEntryPath {
base: string;

dir: string;
Expand Down

0 comments on commit d4db60a

Please sign in to comment.