opral / inlang-message-sdk

0 stars 0 forks source link

remove `tryCatch` stuff from inlang message sdk #27

Open samuelstroschein opened 2 months ago

samuelstroschein commented 2 months ago

Proposal

Remove the tryCatch stuff from message SDK in favor of standard JS.

Value of tryCatch is close to 0

@samuel.stroschein said in LIX-59:

EDIT: never mind. the value of tryCatch is close to 0.

@jldec what is your issue with the utility function tryCatch()? The function doesn't impact API design.

const file = await tryCatch(() => repo.fs.readFile())

if (file.error){
  // do something
}

const parsed = tryCatch(() => JSON.parse(file.value))

if (parsed.error){
  // do something
}
try {

  const file = await repo.fs.readFile()
  const parsed = JSON.parse(file)

} catch (e){
  if (e instanceof FileError){
    //
  } else if (e instanceof JSONError){
    //
  }
}
samuelstroschein commented 2 months ago

if you remove it, can you check if tryCatch is used somewhere else in the monorepo? If not, i vote to remove the function from @inlang/result

jldec commented 2 months ago

used in 3 files in the manage package.

samuelstroschein commented 2 months ago

@jldec remove in manage package too and then remove the function alltogether?

jldec commented 2 months ago

sounds good - ref: INWEB-55

samuelstroschein commented 2 months ago

INWEB-55 :)