Package
@google-cloud/error-reportingConstructors
(constructor)()
constructor();
The constructor for ErrorMessage takes no arguments and is solely meant to to instantiate properties on the instance. Each property should be externally set using the corresponding set function with the exception of eventTime which can be set externally but does not need to be since it is inited to an ISO-8601 compliant time string. {Object} ErrorMessage ErrorMessage is a class which is meant to store and control-for Stackdriver Error API submittable values. Meant to be JSON string-ifiable representation of the final values which will be submitted to the Error API this class enforces type-checking on every setter function and will write default type-friendly values to instance properties if given values which are type-incompatible to expectations. These type-friendly default substitutions will occur silently and no errors will be thrown on attempted invalid input under the premise that during misassignment some error information sent to the Error API is better than no error information due to the Error library failing under invalid input. {String} eventTime - an ISO-8601 compliant string representing when the error was created {Object} serviceContext - The service information for the error {String} serviceContext.service - The service that the error was was produced on {String|Undefined} serviceContext.version - The service version that the error was produced on {String} message - The error message {Object} context - the request, user and report context {Object} context.httpRequest - the request context {String} context.httpRequest.method - the request method (e.g. GET) {String} context.httpRequest.url - the request url or path {String} context.httpRequest.userAgent - the requesting user-agent {String} context.httpRequest.referrer - the request referrer {Number} context.httpRequest.responseStatusCode - the request status-code {String} context.httpRequest.remoteIp - the requesting remote ip {String} context.user - the vm instances user {Object} context.reportLocation - the report context {String} context.reportLocation.filePath - the file path of the report site {Number} context.reportLocation.lineNumber - the line number of the report site {String} context.reportLocation.functionName - the function name of the report site
Properties
context
context: Context;
eventTime
eventTime: string;
message
message: string;
serviceContext
serviceContext: ServiceContext;
Methods
consumeRequestInformation(requestInformation)
consumeRequestInformation(requestInformation: RequestInformationContainer): this;
Consumes the standard object created by the requestInformationExtractors and assigns the properties of the object onto the instance.
Name | Description |
requestInformation |
RequestInformationContainer
the standardized object created by the information extractors |
Type | Description |
this | {this} - returns the instance for chaining |
setEventTimeToNow()
setEventTimeToNow(): this;
Sets the eventTime property on the instance to an ISO-8601 compliant string representing the current time at invocation. setEventTimeToNow
Type | Description |
this | {this} - returns the instance for chaining |
setFilePath(filePath)
setFilePath(filePath?: string): this;
Sets the context.reportLocation.filePath property on the instance
Name | Description |
filePath |
string
the vm instances filePath |
Type | Description |
this | {this} - returns the instance for chaining |
setFunctionName(functionName)
setFunctionName(functionName?: string): this;
Sets the context.reportLocation.functionName property on the instance
Name | Description |
functionName |
string
the function name of the report context |
Type | Description |
this | {this} - returns the instance for chaining |
setHttpMethod(method)
setHttpMethod(method?: string): this;
Sets the context.httpRequest.method property on the instance.
Name | Description |
method |
string
the HTTP method on the request which caused the errors instantiation |
Type | Description |
this | {this} - returns the instance for chaining |
setLineNumber(lineNumber)
setLineNumber(lineNumber?: number): this;
Sets the context.reportLocation.lineNumber property on the instance
Name | Description |
lineNumber |
number
the line number of the report context |
Type | Description |
this | {this} - returns the instance for chaining |
setMessage(message)
setMessage(message?: string): this;
Sets the message property on the instance.
Name | Description |
message |
string
the error message |
Type | Description |
this | {this} - returns the instance for chaining |
setReferrer(referrer)
setReferrer(referrer?: string): this;
Sets the context.httpRequest.referrer property on the instance.
Name | Description |
referrer |
string
the requests referrer |
Type | Description |
this | {this} - returns the instance for chaining |
setRemoteIp(remoteIp)
setRemoteIp(remoteIp?: string): this;
Sets the context.httpRequest.remoteIp property on the instance
Name | Description |
remoteIp |
string
the requesters remote IP |
Type | Description |
this | {this} - returns the instance for chaining |
setResponseStatusCode(responseStatusCode)
setResponseStatusCode(responseStatusCode?: number): this;
Sets the context.httpRequest.responseStatusCode property on the instance.
Name | Description |
responseStatusCode |
number
the response status code |
Type | Description |
this | {this} - returns the instance for chaining |
setServiceContext(service, version)
setServiceContext(service?: string, version?: string): this;
Sets the serviceContext property on the instance and its two constituent properties: service and version. setServiceContext
Name | Description |
service |
string
the service the error was reported on |
version |
string
the version the service was on when the error was reported |
Type | Description |
this | {this} - returns the instance for chaining |
setUrl(url)
setUrl(url?: string): this;
Sets the context.httpRequest.url property on the instance.
Name | Description |
url |
string
the requests target url |
Type | Description |
this | {this} - returns the instance for chaining |
setUser(user)
setUser(user?: string): this;
Sets the context.user property on the instance
Name | Description |
user |
string
the vm instances user |
Type | Description |
this | {this} - returns the instance for chaining |
setUserAgent(userAgent)
setUserAgent(userAgent?: string): this;
Sets the context.httpRequest.userAgent property on the instance.
Name | Description |
userAgent |
string
the requests user-agent |
Type | Description |
this | {this} - returns the instance for chaining |