Improving error messages.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-10-08 20:59:57 -05:00
parent f09b7bd0e9
commit c1c372ced8
1 changed files with 15 additions and 15 deletions

View File

@ -26,9 +26,9 @@ LeDatabase >> addPageFromMarkdeep: markdeepDocTree [
page children collect: [ :snippet |
(self hasBlockUID: (snippet uid))
ifTrue: [ | existingPage |
existingPage := self pages detect: [ :pageTemp |
pageTemp includesSnippetUid: snippet uid ].
^ self errorCardFor: (self importErrorMessage: existingPage) ]
existingPage := self pages detect: [ :pageTemp | pageTemp includesSnippetUid: snippet uid ].
self importErrorMessage: existingPage.
^ self ]
ifFalse: [
snippet database: self.
self registerSnippet: snippet ] ].
@ -41,7 +41,7 @@ LeDatabase >> addPageFromMarkdeepUrl: aString [
| page |
page := self detectLocalPageForRemote: aString.
page ifNotNil: [ :arg | self errorCardFor: (self importErrorMessage: page).
page ifNotNil: [ :arg | (self importErrorMessage: page).
^ self ].
^ self addPageFromMarkdeep: (self docTreeForLink: aString)
]
@ -68,27 +68,27 @@ LeDatabase >> errorCardFor: errorMessage [
keepButton := BrButton new
aptitude: BrGlamorousButtonWithIconAndLabelAptitude;
beTinySize;
label: 'Keep existing page';
label: 'Keep existing local page';
icon: BrGlamorousVectorIcons cancel;
action: [ :aButton | ];
margin: (BlInsets left: 10).
overwriteButton := BrButton new
aptitude: BrGlamorousButtonWithIconAndLabelAptitude;
beTinySize;
label: 'Overwrite page';
label: 'Overwrite with remote page';
icon: BrGlamorousVectorIcons edit;
action: [ :aButton | ];
margin: (BlInsets left: 10).
backupButton := BrButton new
aptitude: BrGlamorousButtonWithIconAndLabelAptitude;
beTinySize;
label: 'BackUp page';
label: 'Backup local page';
icon: BrGlamorousVectorIcons changes;
action: [ :aButton | ];
margin: (BlInsets left: 10).
errorMessageUI := BrEditor new
aptitude: BrGlamorousRegularEditorAptitude new "+ aModeLook;";
aptitude: BrGlamorousRegularEditorAptitude new ;
text: errorMessage;
vFitContent.
^ { errorMessageUI. keepButton. overwriteButton. backupButton }
@ -126,22 +126,22 @@ LeDatabase >> importErrorMessage: page [
id := page uidString.
message := String streamContents: [ :stream |
stream
nextPutAll: 'IMPORTATION ERROR: a page with';
nextPut: Character lf;
nextPutAll: 'IMPORTATION ERROR: A page with
';
nextPut: Character lf;
nextPutAll: ' id: ' , id;
nextPut: Character lf;
nextPutAll: ' title: ' , page contentAsString;
nextPut: Character lf;
nextPut: Character lf;
nextPutAll: 'already exists in this database.';
nextPutAll: 'already exists in this database and includes overlapping contents';
nextPut: Character lf;
nextPutAll: 'with the page you are trying to import.';
nextPut: Character lf;
nextPut: Character lf;
nextPutAll:
'Please do one of those before retrying this procedure:
1) Move the existing page files (.lepiter and .bak) to another (sub)folder.
2) Import the page url to another database.' ].
'Please choose one of the following options to addres the issue:
' ].
self errors at: id put: message
]