# vim:ts=2:sw=2:et:si:ai: # The API sends back messages via the p4.messages attribute if there was an # error with the last command. We will often convert that to this exception, # which will be formatted into JSON. require 'P4' # 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. class P4Error < RuntimeError # All error codes must be greater than this number. ERROR_CODE_BASE = 15_360 # Note: We use 15_361 for 'unhandled' ruby errors attr_accessor :message_code, :message_severity, :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. def self.default_error(message_text) P4Error.new(ERROR_CODE_BASE, P4::E_FAILED, message_text) end # Returns true if there's an error def self.error?(p4, severity: P4::E_FAILED) return p4.messages && p4.messages.any? {|m| m.severity >= severity} end def initialize(code, severity, text) @message_code = code @message_severity = severity @message_text = text end # Returns true if the exception should actually be considered a user error # instead of a system exception. def user_error? return @message_severity == P4::E_FAILED end # Returns true if the exception is truly a system problem. def system_error? return @message_severity == P4::E_FATAL end def to_s @message_text end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15688 | Doug Scheirer |
Populate -o //guest/perforce_software/helix-web-services/... //guest/doug_scheirer/helix-web-services/.... |
||
//guest/perforce_software/helix-web-services/main/source/helix_web_services/lib/p4_error.rb | |||||
#2 | 15687 | tjuricek |
Associate 400 status codes for severity 3 exceptions and 500 for severity 4. We don't throw P4Exception for severity < 3 at the moment, since those are typically just warnings, like "you have no files in that directory". |
||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services/lib/p4_error.rb | |||||
#2 | 15110 | tjuricek | Revise changes methods for new p4 connection handling, add server specs, remove model references in client, and update asciidoc documentation. | ||
#1 | 13799 | tjuricek |
Start with branch specs hosting in a new monolithic 'helix web services' project. Converting from a microservice to a monolithic architecture due to resource constraints at getting a deployable system running. Additionally, since it's not expected that people will upgrade often, the major benefit of microservices - being able to add services individually without affecting others - is not really a major benefit. The Ruby SDK will be consolidated into a single 'helix web services client' project. It may end up being distributed via Rubygems. This only runs branch specs at the moment. I want to get a CD pipeline setup for the monolithic server before revising more methods. |
||
//guest/perforce_software/helix-web-services/main/p4_web_api/p4_web_api/lib/p4_web_api/p4_error.rb | |||||
#1 | 13412 | tjuricek |
Initial version of the web-services mainline. This is a collection of several projects, that will likely often get released together, though many of them may not always be relevant. See the README for more information. |