{"record":{"id":"06a20adc6ba5eaa9","repo":"prestodb/presto","slug":"format-formatstring-args","errorCode":null,"errorMessage":"format(formatString, args)","messagePattern":"format\\(formatString, args\\)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/util/Failures.java","lineNumber":90,"sourceCode":"\n    public static void checkArgument(boolean expression, String errorMessage)\n    {\n        if (!expression) {\n            throw new PrestoException(StandardErrorCode.INVALID_ARGUMENTS, errorMessage);\n        }\n    }\n\n    public static void checkArgument(boolean expression, String errorMessageTemplate, Object... errorMessageArgs)\n    {\n        if (!expression) {\n            throw new PrestoException(StandardErrorCode.INVALID_ARGUMENTS, String.format(errorMessageTemplate, errorMessageArgs));\n        }\n    }\n\n    public static void checkCondition(boolean condition, ErrorCodeSupplier errorCode, String formatString, Object... args)\n    {\n        if (!condition) {\n            throw new PrestoException(errorCode, format(formatString, args));\n        }\n    }\n\n    public static List<ExecutionFailureInfo> toFailures(Collection<? extends Throwable> failures)\n    {\n        return failures.stream()\n                .map(Failures::toFailure)\n                .collect(toImmutableList());\n    }\n\n    private static ExecutionFailureInfo toFailure(Throwable throwable, Set<Throwable> seenFailures)\n    {\n        if (throwable == null) {\n            return null;\n        }\n\n        String type;\n        HostAddress remoteHost = null;","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/util/Failures.java#L72-L108","documentation":"Failures.checkCondition is the general-purpose precondition helper: when condition is false it throws PrestoException with the caller-supplied ErrorCodeSupplier and a message built by format(formatString, args). Unlike checkArgument it lets call sites choose the error code, so it is used for user-facing semantic errors beyond plain argument validation.","triggerScenarios":"Any call to Failures.checkCondition(cond, errorCode, fmt, args...) where cond is false — e.g. session/property validation, function semantic checks, or connector checks that map to a specific SQL error code.","commonSituations":"Invalid session properties or catalog/schema state; queries violating function semantics (e.g. invalid hex, unsupported units); misconfigured connectors failing precondition checks at planning time.","solutions":["Read the formatted message and the accompanying error code to identify the exact failing condition","Correct the query or configuration item the message points to","Use try_* functions or WHERE guards to filter out offending rows for data-dependent failures","Check feature/version compatibility — some checks fire when using features unsupported by the connected catalog"],"exampleFix":"-- before\nSELECT from_hex('ZZ') ; -- invalid hex\n-- after\nSELECT from_hex(x) FROM t WHERE regexp_like(x, '^[0-9A-Fa-f]*$');","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* op */ } catch (PrestoException e) { Supplier<? extends ErrorCode> ec = e.getErrorCode(); log.error(\"checkCondition failed [{}]: {}\", ec, e.getMessage()); /* branch on ec to recover or rethrow */ }","preventionTips":["Use the error code in the exception to branch handling precisely","Validate session properties and catalog configuration before running queries","Use try_* variants for data that may violate function semantics"],"tags":["presto","presto-exception","condition-check"],"backgroundTag":"invalid-argument","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}