Package com.moeen.shared_lib.exception
Record Class ErrorResponse
java.lang.Object
java.lang.Record
com.moeen.shared_lib.exception.ErrorResponse
public record ErrorResponse(Instant timestamp, int status, String error, String message, String path, String traceId, Map<String,Object> details)
extends Record
Standardized error response body used across all microservices.
Includes a trace ID for distributed tracing correlation and
uses
Instant for timezone-safe timestamps.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondetails()Returns the value of thedetailsrecord component.final booleanIndicates whether some other object is "equal to" this one.error()Returns the value of theerrorrecord component.final inthashCode()Returns a hash code value for this object.message()Returns the value of themessagerecord component.static ErrorResponseof(org.springframework.http.HttpStatusCode status, String error, String message, org.springframework.web.context.request.WebRequest request, @Nullable Map<String, Object> details) path()Returns the value of thepathrecord component.intstatus()Returns the value of thestatusrecord component.Returns the value of thetimestamprecord component.org.springframework.http.ResponseEntity<Object> org.springframework.http.ResponseEntity<Object> toResponseEntity(org.springframework.http.HttpHeaders headers) final StringtoString()Returns a string representation of this record class.traceId()Returns the value of thetraceIdrecord component.
-
Constructor Details
-
ErrorResponse
public ErrorResponse(Instant timestamp, int status, String error, String message, String path, String traceId, Map<String, Object> details) Creates an instance of aErrorResponserecord class.- Parameters:
timestamp- the value for thetimestamprecord componentstatus- the value for thestatusrecord componenterror- the value for theerrorrecord componentmessage- the value for themessagerecord componentpath- the value for thepathrecord componenttraceId- the value for thetraceIdrecord componentdetails- the value for thedetailsrecord component
-
-
Method Details
-
of
-
toResponseEntity
-
toResponseEntity
public org.springframework.http.ResponseEntity<Object> toResponseEntity(org.springframework.http.HttpHeaders headers) -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-
status
public int status()Returns the value of thestatusrecord component.- Returns:
- the value of the
statusrecord component
-
error
Returns the value of theerrorrecord component.- Returns:
- the value of the
errorrecord component
-
message
Returns the value of themessagerecord component.- Returns:
- the value of the
messagerecord component
-
path
Returns the value of thepathrecord component.- Returns:
- the value of the
pathrecord component
-
traceId
Returns the value of thetraceIdrecord component.- Returns:
- the value of the
traceIdrecord component
-
details
Returns the value of thedetailsrecord component.- Returns:
- the value of the
detailsrecord component
-