5

I have a function that computes 2 numbers which determine whether the function should stop or continue its execution. In short, I would like the function to throw an error whenever x is not equal to y as illustrated in the code below.

function er (x,y){
  x = ee.Number(x)
  y = ee.Number(y)
  return ee.Algorithms.If({
    condition: x.eq(y),
    trueCase: x.multiply(y),
    falseCase: 'Stop and throw this error!'
  })
}

print(er(2,1))

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.