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))
Liman
  • 1,270
  • 6
  • 12

0 Answers0