Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Cloud Functions
  • Comparing with other Yandex Cloud services
    • Overview
    • Programming model
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Error handling
  • Tools
  • Pricing policy
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes
  • FAQ
  1. Developing in R
  2. Error handling

R function error handling

Written by
Yandex Cloud
Updated at July 2, 2026
View in Markdown

If the handler reports an R function execution or loading error, the runtime automatically catches the error and returns a JSON document with information about the error type. For more information about the JSON document format, see Invoking a function.

The error info is also written to the execution log. You can view the log via the Yandex Cloud CLI or the management console.

Examples of error handlingExamples of error handling

Case 1: User code goes outside the array boundaries, causing the function to throw non-numeric argument to binary operator. The runtime catches the exception and generates a JSON document containing the error message (the errorMessage field) and error type (the errorType field).

Function code:

handler <-function() {
  return(paste0('{"result":"', "1" + 2,'"}'))
}

JSON document returned:

{
  "errorMessage": "Error in a + b: non-numeric argument to binary operator\n",
  "errorType": "simpleError",
}

Case 2: User code indicates an error by throwing an exception from the function.

Function code:

handler <- function() {
  stop("Some error message")
}

JSON document returned:

{
  "errorMessage": "Error in handler(): Some error message\n",
  "errorType": "simpleError",
}

Was the article helpful?

Previous
Logging
Next
Overview
© 2026 Direct Cursus Technology L.L.C.