Skip to content

Commit

Permalink
fix: Report the root cause of a dictionary error. (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Feb 26, 2021
1 parent 602edd1 commit 8c1debd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/cspell-lib/src/Settings/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './CSpellSettingsServer';
export * from './DefaultSettings';
export * from '@cspell/cspell-types';
export * from './ImportError';
1 change: 1 addition & 0 deletions packages/cspell-lib/src/SpellingDictionary/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './SpellingDictionary';
export * from './SpellingDictionaryCollection';
export * from './Dictionaries';
export * from './createSpellingDictionary';
export * from './SpellingDictionaryError';
2 changes: 2 additions & 0 deletions packages/cspell-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ export {
CompoundWordsMethod,
createSpellingDictionary,
getDictionary,
isSpellingDictionaryLoadError,
refreshDictionaryCache,
SpellingDictionary,
SuggestionCollector,
SuggestionResult,
SpellingDictionaryLoadError,
} from './SpellingDictionary';
export { combineTextAndLanguageSettings } from './Settings/TextDocumentSettings';
export { combineTextAndLanguageSettings as constructSettingsForText } from './Settings/TextDocumentSettings';
Expand Down
6 changes: 5 additions & 1 deletion packages/cspell/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from './link';
import { tableToLines } from './util/table';
import { Emitters, isProgressFileComplete, MessageType, ProgressItem, Issue } from './emitters';
import { isSpellingDictionaryLoadError, SpellingDictionaryLoadError, ImportError } from 'cspell-lib';

interface Options extends CSpellApplicationOptions {
legacy?: boolean;
Expand Down Expand Up @@ -52,7 +53,10 @@ function genIssueEmitter(template: string) {
};
}

function errorEmitter(message: string, error: Error) {
function errorEmitter(message: string, error: Error | SpellingDictionaryLoadError | ImportError) {
if (isSpellingDictionaryLoadError(error)) {
error = error.cause;
}
console.error(chalk.red(message), error.toString());
}

Expand Down

0 comments on commit 8c1debd

Please sign in to comment.