-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract ErrorWithFilteredBacktrace to reduce duplication
- Loading branch information
1 parent
5bda7c4
commit b57c386
Showing
3 changed files
with
21 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'mocha/backtrace_filter' | ||
|
||
module Mocha | ||
|
||
# @private | ||
class ErrorWithFilteredBacktrace < StandardError | ||
|
||
# @private | ||
def initialize(message = nil, backtrace = []) | ||
super(message) | ||
filter = BacktraceFilter.new | ||
set_backtrace(filter.filtered(backtrace)) | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,9 @@ | ||
require 'mocha/backtrace_filter' | ||
require 'mocha/error_with_filtered_backtrace' | ||
|
||
module Mocha | ||
|
||
# Exception raised when Mocha has not been initialized, e.g. outside the | ||
# context of a test. | ||
class NotInitializedError < StandardError | ||
|
||
# @private | ||
def initialize(message = nil, backtrace = []) | ||
super(message) | ||
filter = BacktraceFilter.new | ||
set_backtrace(filter.filtered(backtrace)) | ||
end | ||
|
||
end | ||
class NotInitializedError < ErrorWithFilteredBacktrace; end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
require 'mocha/backtrace_filter' | ||
require 'mocha/error_with_filtered_backtrace' | ||
|
||
module Mocha | ||
|
||
# Exception raised when stubbing a particular method is not allowed. | ||
# | ||
# @see Configuration.prevent | ||
class StubbingError < StandardError | ||
|
||
# @private | ||
def initialize(message = nil, backtrace = []) | ||
super(message) | ||
filter = BacktraceFilter.new | ||
set_backtrace(filter.filtered(backtrace)) | ||
end | ||
|
||
end | ||
class StubbingError < ErrorWithFilteredBacktrace; end | ||
|
||
end |