Getting an error when formatting a thumb drive
You're asking it to partition a whole disk - it wipes existing volumes, and creates the ones you specify.

But, you're giving it /dev/disk1s2, which is itself a partition.

If you're trying to reformat the whole drive, you should be using /dev/disk1

Also, typically, people use eraseDisk to wipe and reformat it - 


  diskutil eraseDisk Usage:  diskutil eraseDisk format name
  [APM[Format]|MBR[Format]|GPT[Format]]
          MountPoint|DiskIdentifier|DeviceNode (Re)-partition a whole disk (create a new partition map). This completely erases any existing
  data on the given whole disk; all volumes on this disk will be
  destroyed. Format is the specific file system name you want to erase
  it as (HFS+, etc.). Name is the (new) volume name (subject to file
  system naming restrictions), or can be specified as %noformat% to skip
  initialization (newfs). You cannot erase the boot disk. Ownership of
  the affected disk is required. Example: diskutil eraseDisk JHFS+
  UntitledUFS disk3