Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/org/joni/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public interface Config extends org.jcodings.Config {
int CHECK_STRING_THRESHOLD_LEN = ConfigSupport.getInt("joni.check_string_threshold_len", 7);
int CHECK_BUFF_MAX_SIZE = ConfigSupport.getInt("joni.check_buff_max_size", 0x4000);

// Whether JOniException and its subclasses record a stack trace when thrown.
// Filling in the stack trace is expensive and the Java stack trace is rarely useful
// (e.g. for a regexp syntax error), so it is disabled by default.
boolean ENABLE_STACK_TRACE = ConfigSupport.getBoolean("org.joni.enableStackTrace", false);

PrintStream log = System.out;
PrintStream err = System.err;

Expand Down
14 changes: 14 additions & 0 deletions src/org/joni/exception/JOniException.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,24 @@
*/
package org.joni.exception;

import org.joni.Config;

public class JOniException extends RuntimeException{
private static final long serialVersionUID = -6027192180014164667L;

public JOniException(String message) {
super(message);
}

// The stacktrace is not very useful and is very expensive,
// for example for Regexp#to_s on a Regexp like /(?i:a)|(?i:b)/,
// so it is omitted unless -Dorg.joni.enableStackTrace=true
@Override
public final Throwable fillInStackTrace() {
if (Config.ENABLE_STACK_TRACE) {
return super.fillInStackTrace();
} else {
return this;
}
}
}
Loading