Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Cloud Functions
  • Comparison with other Yandex Cloud services
    • Overview
    • Programming model
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
  • Tools
  • Pricing policy
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ
  1. Developing in R
  2. Handling errors

R function error handling

Written by
Yandex Cloud
Updated at May 12, 2025

If a handler reports a R function runtime or loading error, the runtime environment automatically captures the error and returns a JSON document with the error type in the response. For more information about the JSON document format, see Calling 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, resulting in non-numeric argument to binary operator. The runtime environment intercepts the exception and generates a JSON document stating the error message (errorMessage field) and error type (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
© 2025 Direct Cursus Technology L.L.C.