Skip to content

Commit

Permalink
Move logging and error handling further up.
Browse files Browse the repository at this point in the history
  • Loading branch information
chhoumann committed Jun 14, 2021
1 parent f7dd5de commit e2f74a9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "quickadd",
"name": "QuickAdd",
"version": "0.1.6",
"version": "0.1.7",
"minAppVersion": "0.12.00",
"description": "Quickly add new pages or content to your vault.",
"author": "Christian B. B. Houmann",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quickadd",
"version": "0.1.6",
"version": "0.1.7",
"description": "Quickly add new pages or content to your vault.",
"main": "main.js",
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion src/engine/CaptureChoiceEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class CaptureChoiceEngine extends QuickAddChoiceEngine {
await this.app.vault.modify(file, newFileContent);
} else {
const formattedContent = await this.formatter.formatContent(content, this.choice);
if (!formattedContent) return;

const createdFile = await this.createFileWithInput(filePath, formattedContent);

if (!createdFile) {
Expand All @@ -56,7 +58,7 @@ export class CaptureChoiceEngine extends QuickAddChoiceEngine {
appendToCurrentLine(`[[${filePath.replace(MARKDOWN_FILE_EXTENSION_REGEX, '')}]]`, this.app);
}
catch (e) {
log.logError(e);
log.logMessage(e);
}
}

Expand Down Expand Up @@ -86,6 +88,7 @@ export class CaptureChoiceEngine extends QuickAddChoiceEngine {
content = await this.formatter.formatContent(content, this.choice);
}

if (!content) return;
appendToCurrentLine(content, this.app);
}
}
28 changes: 11 additions & 17 deletions src/formatters/completeFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {MARKDOWN_FILE_EXTENSION_REGEX} from "../constants";
import {getNaturalLanguageDates} from "../utility";
import GenericInputPrompt from "../gui/GenericInputPrompt/genericInputPrompt";
import GenericSuggester from "../gui/GenericSuggester/genericSuggester";
import {log} from "../logger/logManager";
import type QuickAdd from "../main";
import {SingleMacroEngine} from "../engine/SingleMacroEngine";
import {SingleTemplateEngine} from "../engine/SingleTemplateEngine";
Expand All @@ -17,21 +16,16 @@ export class CompleteFormatter extends Formatter {
}

protected async format(input: string): Promise<string> {
try {
let output: string = input;

output = this.replaceDateInString(output);
output = await this.replaceValueInString(output);
output = await this.replaceDateVariableInString(output);
output = await this.replaceVariableInString(output);
output = await this.replaceMacrosInString(output);
output = await this.replaceTemplateInString(output);

return output;
}
catch (e) {
log.logError(e);
}
let output: string = input;

output = this.replaceDateInString(output);
output = await this.replaceValueInString(output);
output = await this.replaceDateVariableInString(output);
output = await this.replaceVariableInString(output);
output = await this.replaceMacrosInString(output);
output = await this.replaceTemplateInString(output);

return output;
}

async formatFileName(input: string, valueHeader: string): Promise<string> {
Expand Down Expand Up @@ -65,7 +59,7 @@ export class CompleteFormatter extends Formatter {

protected async promptForValue(header?: string): Promise<string> {
if (!this.value)
this.value = await GenericInputPrompt.Prompt(this.app, this.valueHeader ?? `Enter value`);
this.value = await GenericInputPrompt.Prompt(this.app, this.valueHeader ?? `Enter value`)

return this.value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/ChoiceBuilder/captureChoiceBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ChoiceBuilder} from "./choiceBuilder";
import type ICaptureChoice from "../../types/choices/ICaptureChoice";
import type {App} from "obsidian";
import {SearchComponent, Setting, TextAreaComponent, TextComponent, ToggleComponent} from "obsidian";
import {Setting, TextAreaComponent, TextComponent, ToggleComponent} from "obsidian";
import {FormatSyntaxSuggester} from "../formatSyntaxSuggester";
import {FILE_NAME_FORMAT_SYNTAX, FORMAT_SYNTAX} from "../../constants";
import {FormatDisplayFormatter} from "../../formatters/formatDisplayFormatter";
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"0.1.6": "0.12.4"
"0.1.7": "0.12.4"
}

0 comments on commit e2f74a9

Please sign in to comment.