Exception: P4Error
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- P4Error
- Defined in:
- lib/p4_error.rb
Overview
Any error we get from the Perforce server is generally encapsulated in a P4Error, which allows us to get some basic diagnostic information from the Perforce server out to the user.
Direct Known Subclasses
Constant Summary
- ERROR_CODE_BASE =
All error codes must be greater than this number.
15_360
Instance Attribute Summary (collapse)
-
- (Object) message_code
Note: We use 15_361 for 'unhandled' ruby errors.
-
- (Object) message_severity
Note: We use 15_361 for 'unhandled' ruby errors.
-
- (Object) message_text
Note: We use 15_361 for 'unhandled' ruby errors.
Class Method Summary (collapse)
-
+ (Object) default_error(message_text)
Class method to create a valid P4Error object from a simple string.
-
+ (Boolean) error?(p4, severity: P4::E_FAILED)
Returns true if there's an error.
Instance Method Summary (collapse)
-
- (P4Error) initialize(code, severity, text)
constructor
A new instance of P4Error.
-
- (Boolean) system_error?
Returns true if the exception is truly a system problem.
- - (Object) to_s
-
- (Boolean) user_error?
Returns true if the exception should actually be considered a user error instead of a system exception.
Constructor Details
- (P4Error) initialize(code, severity, text)
Returns a new instance of P4Error
32 33 34 35 36 |
# File 'lib/p4_error.rb', line 32 def initialize(code, severity, text) @message_code = code @message_severity = severity @message_text = text end |
Instance Attribute Details
- (Object) message_code
Note: We use 15_361 for 'unhandled' ruby errors
16 17 18 |
# File 'lib/p4_error.rb', line 16 def @message_code end |
- (Object) message_severity
Note: We use 15_361 for 'unhandled' ruby errors
16 17 18 |
# File 'lib/p4_error.rb', line 16 def @message_severity end |
- (Object) message_text
Note: We use 15_361 for 'unhandled' ruby errors
16 17 18 |
# File 'lib/p4_error.rb', line 16 def @message_text end |
Class Method Details
+ (Object) default_error(message_text)
Class method to create a valid P4Error object from a simple string. Used when we get errors for which no P4::Message object is available.
21 22 23 24 25 |
# File 'lib/p4_error.rb', line 21 def self.default_error() P4Error.new(ERROR_CODE_BASE, P4::E_FAILED, ) end |
+ (Boolean) error?(p4, severity: P4::E_FAILED)
Returns true if there's an error
28 29 30 |
# File 'lib/p4_error.rb', line 28 def self.error?(p4, severity: P4::E_FAILED) return p4. && p4..any? {|m| m.severity >= severity} end |
Instance Method Details
- (Boolean) system_error?
Returns true if the exception is truly a system problem.
45 46 47 |
# File 'lib/p4_error.rb', line 45 def system_error? return @message_severity == P4::E_FATAL end |
- (Object) to_s
49 50 51 |
# File 'lib/p4_error.rb', line 49 def to_s @message_text end |
- (Boolean) user_error?
Returns true if the exception should actually be considered a user error instead of a system exception.
40 41 42 |
# File 'lib/p4_error.rb', line 40 def user_error? return @message_severity == P4::E_FAILED end |