867 context:(in JSContext *)context
868 error:(in JSErrorReport *)errorReport
869 stackSkip:(in unsigned)stackSkip
870 showingLocation:(in BOOL)showLocation
871 withMessage:(in NSString *)message
872{
873 NSString *colorKey =
nil;
874 NSString *prefix =
nil;
875 NSString *filePath =
nil;
876 NSString *sourceLine =
nil;
877 NSString *scriptLine =
nil;
878 NSMutableString *formattedMessage =
nil;
879 NSRange emphasisRange;
880 NSString *showKey =
nil;
881
882 if (_debugger ==
nil)
return;
883
884 if (errorReport->flags & JSREPORT_WARNING)
885 {
886 colorKey = @"warning";
887 prefix = @"Warning";
888 }
889 else if (errorReport->flags & JSREPORT_EXCEPTION)
890 {
891 colorKey = @"exception";
892 prefix = @"Exception";
893 }
894 else
895 {
896 colorKey = @"error";
897 prefix = @"Error";
898 }
899
900 if (errorReport->flags & JSREPORT_STRICT)
901 {
902 prefix = [prefix stringByAppendingString:@" (strict mode)"];
903 }
904
905
906 emphasisRange = NSMakeRange(0, [prefix length] + 1);
907
908 formattedMessage = [NSMutableString stringWithFormat:@"%@: %@", prefix, message];
909
910
911
912
913
915 scriptLine = [[thisScript weakRefUnderlyingObject] displayName];
916 [thisScript release];
917
918 if (scriptLine !=
nil)
919 {
920 [formattedMessage appendFormat:@"\n Active script: %@", scriptLine];
921 }
922
923 if (showLocation && stackSkip == 0)
924 {
925
926 if (errorReport->filename != NULL) filePath = [NSString stringWithUTF8String:errorReport->filename];
927 if ([filePath length] != 0)
928 {
929 [formattedMessage appendFormat:@"\n %@, line %u", [filePath lastPathComponent], errorReport->lineno];
930
931
932 sourceLine = [self sourceCodeForFile:filePath line:errorReport->lineno];
933 if (sourceLine !=
nil)
934 {
935 [formattedMessage appendFormat:@":\n %@", sourceLine];
936 }
937 }
938 }
939
940 [self appendJSConsoleLine:formattedMessage
941 colorKey:colorKey
942 emphasisRange:emphasisRange];
943
944 if (errorReport->flags & JSREPORT_WARNING) showKey = @"show-console-on-warning";
945 else showKey = @"show-console-on-error";
947 {
948 [self showJSConsole];
949 }
950}
OOJSScript * currentlyRunningScript()