Skip to content

Commit

Permalink
Write errors to standard error
Browse files Browse the repository at this point in the history
  • Loading branch information
stoeffn committed Feb 6, 2018
1 parent 69d6862 commit 40a4878
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Pseudo/Application.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (BOOL) executeFilesAtFilePaths: (NSArray<NSString *> *) filePaths {
}];

if (error) {
[PSConsole writeString: [[NSString alloc] initWithFormat: @"%@\n", error.localizedDescription]];
[PSConsole writeErrorString: [[NSString alloc] initWithFormat: @"%@\n", error.localizedDescription]];
return NO;
}

Expand Down
2 changes: 2 additions & 0 deletions PseudoKit/PSConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@

+ (void) writeString: (nonnull NSString *) string;

+ (void) writeErrorString: (nonnull NSString *) string;

@end
5 changes: 5 additions & 0 deletions PseudoKit/PSConsole.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ + (void) writeString: (nonnull NSString *) string {
[NSFileHandle.fileHandleWithStandardOutput writeData: data];
}

+ (void) writeErrorString: (nonnull NSString *) string {
NSData *data = [string dataUsingEncoding: NSUTF8StringEncoding];
[NSFileHandle.fileHandleWithStandardError writeData: data];
}

#pragma mark - Constants

+ (nonnull NSCharacterSet *) illegalAndControlCharacterSet {
Expand Down
2 changes: 1 addition & 1 deletion PseudoKit/REPL/PSREPL.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ - (void) handleREPLInput: (NSString *) input {
[self.buffer removeAllObjects];

if (error) {
return [PSConsole writeString: [[NSString alloc] initWithFormat: @"%@\n", error.localizedDescription]];
return [PSConsole writeErrorString: [[NSString alloc] initWithFormat: @"%@\n", error.localizedDescription]];
}

if (result && result.length > 0) {
Expand Down

0 comments on commit 40a4878

Please sign in to comment.