protected UserException(final DremioPBError.ErrorType errorType, final String message, final Throwable cause, final ByteString rawAdditionalContext) { super(message, cause); this.errorType = errorType; this.context = new UserExceptionContext(); this.rawAdditionalContext = rawAdditionalContext; }
/** * add a string line to the bottom of the context * @param value string line * @return this builder */ public Builder addContext(final String value) { context.add(value); return this; }
public List<String> getContextStrings() { return context.getContextAsStrings(); }
/** * returns or creates a DremioPBError object corresponding to this user exception. * * @param verbose should the error object contain the verbose error message ? * @return protobuf error object */ public DremioPBError getOrCreatePBError(final boolean verbose) { final DremioPBError.Builder builder = DremioPBError.newBuilder(); builder.setErrorType(errorType); builder.setErrorId(context.getErrorId()); if (context.getEndpoint() != null) { builder.setEndpoint(context.getEndpoint()); } builder.setMessage(getVerboseMessage()); builder.setOriginalMessage(getOriginalMessage()); if (getCause() != null) { // some unit tests use this information to make sure a specific exception was thrown in the server builder.setException(ErrorHelper.getWrapper(getCause())); } builder.addAllContext(context.getContextAsStrings()); if (rawAdditionalContext != null) { builder.setTypeSpecificContext(rawAdditionalContext); } return builder.build(); }
/** * pushes a string value to the top of the context * * @param value context value * @return this builder */ public Builder pushContext(final String value) { context.push(value); return this; }
public String getErrorIdWithIdentity() { final NodeEndpoint endpoint = context.getEndpoint(); if (endpoint == null ) { return "ErrorId: " + context.getErrorId(); } else { return "ErrorId: " + context.getErrorId() + " on " + endpoint.getAddress() + ":" + endpoint.getUserPort(); } }
public String getErrorId() { return context.getErrorId(); }
/** * Generates a user error message that has the following structure: * ERROR TYPE: ERROR_MESSAGE * CONTEXT * [ERROR_ID on NODE_IP:NODE_USER_PORT] * * @return generated user error message */ private String generateMessage(boolean includeErrorIdAndIdentity) { return errorType + " ERROR: " + super.getMessage() + "\n\n" + context.generateContextMessage(includeErrorIdAndIdentity); } }
public String getErrorLocation() { NodeEndpoint ep = context.getEndpoint(); if (ep != null) { return ep.getAddress() + ":" + ep.getUserPort(); } else { return null; } }
/** * pushes a long value to the top of the context list * @param context context name * @param value context value */ void push(String context, long value) { push(context + " " + value); }
/** * adds a sring value to the bottom of the context list * @param context context name * @param value context value */ void add(String context, String value) { add(context + " " + value); }
/** * adds a double at the top of the context list * @param context context name * @param value context value */ void push(String context, double value) { push(context + " " + value); }
this.message = cause != null ? cause.getMessage() : null; this.context = new UserExceptionContext();
/** * adds a long value to the bottom of the context list * @param context context name * @param value context value */ void add(String context, long value) { add(context + " " + value); }
/** * pushes a long value to the top of the context * * @param name context name * @param value context value * @return this builder */ public Builder pushContext(final String name, final long value) { context.push(name, value); return this; }
/** * adds a double to the bottom of the context list * @param context context name * @param value context value */ void add(String context, double value) { add(context + " " + value); }
/** * pushes a double value to the top of the context * * @param name context name * @param value context value * @return this builder */ public Builder pushContext(final String name, final double value) { context.push(name, value); return this; }
/** * add a string value to the bottom of the context * * @param name context name * @param value context value * @return this builder */ public Builder addContext(final String name, final String value) { context.add(name, value); return this; }
/** * pushes a string value to the top of the context list * @param context context name * @param value context value */ void push(String context, String value) { push(context + " " + value); }
/** * add NodeEndpoint identity to the context. * <p>if the context already has a node endpoint identity, the new identity will be ignored * * @param endpoint node endpoint identity */ public Builder addIdentity(final CoordinationProtos.NodeEndpoint endpoint) { context.add(endpoint); return this; }